-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(hook): maintain CLS context in after hooks
#9473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
encapsulate promises returned by `retry-as-promised` with `Promise.resolve` to maintain CLS context fix sequelize#9472
|
Hmm so you are saying this can also fix #9071, Can you add a test for this with other cls tests? |
|
@sushantdhiman Ok, I'll give it a try |
…ly patched Promises returned by sequelize.query must be correctly patched to maintain CLS context
|
@sushantdhiman I added a simple test case which fails in current master and passes with my PR. |
test/integration/cls.test.js
Outdated
| }); | ||
|
|
||
| it('promises returned by sequelize.query are correctly patched', function() { | ||
| const self = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No self = this
| expect(Sequelize._cls).to.equal(this.ns); | ||
| }); | ||
|
|
||
| it('promises returned by sequelize.query are correctly patched', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a real world test, create row under transaction, try to access that row in nested context assuming cls context is passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or may be take inspiration from #9383 (2nd test looks neat)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's already almost exactly the 2nd test from #9383.
I just removed the first two .then(), which are useless because the first sequelize.query() already returns a non-patched promise.
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Encapsulate promises returned by
retry-as-promisedwithPromise.resolveto maintain CLS context inafterXXXhooks.fix #9472
fix #9071