fix(hook): maintain CLS context in after
hooks
#9473
Merged
Conversation
encapsulate promises returned by `retry-as-promised` with `Promise.resolve` to maintain CLS context fix #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 |
3 commits
May 24, 2018
added …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
@@ -164,5 +164,17 @@ if (current.dialect.supports.transactions) { | |||
it('CLS namespace is stored in Sequelize._cls', function() { | |||
expect(Sequelize._cls).to.equal(this.ns); | |||
}); | |||
|
|||
it('promises returned by sequelize.query are correctly patched', function() { | |||
const self = this; |
sushantdhiman
May 25, 2018
Contributor
No self = this
No self = this
@@ -164,5 +164,17 @@ if (current.dialect.supports.transactions) { | |||
it('CLS namespace is stored in Sequelize._cls', function() { | |||
expect(Sequelize._cls).to.equal(this.ns); | |||
}); | |||
|
|||
it('promises returned by sequelize.query are correctly patched', function() { |
sushantdhiman
May 25, 2018
Contributor
Needs a real world test, create row under transaction, try to access that row in nested context assuming cls context is passed
Needs a real world test, create row under transaction, try to access that row in nested context assuming cls context is passed
msuret
May 25, 2018
Author
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.
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.
This was referenced May 25, 2018
sushantdhiman
added a commit
that referenced
this pull request
May 25, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Pull Request check-list
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description of change
Encapsulate promises returned by
retry-as-promised
withPromise.resolve
to maintain CLS context inafterXXX
hooks.fix #9472
fix #9071