async_hooks: fix id assignment in fast-path promise hook#34548
Closed
puzpuzpuz wants to merge 1 commit intonodejs:masterfrom
Closed
async_hooks: fix id assignment in fast-path promise hook#34548puzpuzpuz wants to merge 1 commit intonodejs:masterfrom
puzpuzpuz wants to merge 1 commit intonodejs:masterfrom
Conversation
de142ac to
61cf759
Compare
addaleax
approved these changes
Jul 30, 2020
61cf759 to
c03a3ad
Compare
addaleax
reviewed
Jul 30, 2020
c03a3ad to
2823ac3
Compare
addaleax
approved these changes
Jul 31, 2020
Collaborator
Member
Author
|
@addaleax thanks for the helpful review! |
benjamingr
approved these changes
Jul 31, 2020
Member
|
Looks like the debug build breaks here with a linking error – you may want to add something like // TODO(addaleax): Remove once we're on C++17.
constexpr double AsyncWrap::kInvalidAsyncId;somewhere (this is a common issue with C++14, you can search the codebase for more instances of the |
Native side of fast-path promise hook was not calling JS fastPromiseHook function when there were no async ids previously assigned to the promise. Because of that already created promises could not get id assigned in situations when an async hook without a before listener function is enabled after their creation. As the result executionAsyncId could return wrong id when called within promise's .then(). Refs: nodejs#34512
2823ac3 to
f6059e3
Compare
Member
Author
|
@addaleax thanks for sharing this workaround. I've added the duplicate |
This was referenced Aug 1, 2020
Collaborator
Collaborator
This was referenced Aug 2, 2020
Flarna
approved these changes
Aug 3, 2020
puzpuzpuz
added a commit
that referenced
this pull request
Aug 3, 2020
Native side of fast-path promise hook was not calling JS fastPromiseHook function when there were no async ids previously assigned to the promise. Because of that already created promises could not get id assigned in situations when an async hook without a before listener function is enabled after their creation. As the result executionAsyncId could return wrong id when called within promise's .then(). Refs: #34512 PR-URL: #34548 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Member
Author
|
Landed in b7a2329 |
12 tasks
This was referenced Aug 4, 2020
codebytere
pushed a commit
that referenced
this pull request
Aug 6, 2020
Native side of fast-path promise hook was not calling JS fastPromiseHook function when there were no async ids previously assigned to the promise. Because of that already created promises could not get id assigned in situations when an async hook without a before listener function is enabled after their creation. As the result executionAsyncId could return wrong id when called within promise's .then(). Refs: #34512 PR-URL: #34548 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This was referenced Aug 7, 2020
Merged
codebytere
pushed a commit
that referenced
this pull request
Aug 11, 2020
Native side of fast-path promise hook was not calling JS fastPromiseHook function when there were no async ids previously assigned to the promise. Because of that already created promises could not get id assigned in situations when an async hook without a before listener function is enabled after their creation. As the result executionAsyncId could return wrong id when called within promise's .then(). Refs: #34512 PR-URL: #34548 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug introduced by #34512.
Native side of fast-path promise hook was not calling JS
fastPromiseHookfunction when there were no async ids previously assigned to the promise. Because of that already created promises could not get id assigned in situations when an async hook without a before listener function is enabled after their creation. As the resultexecutionAsyncIdcould return wrong id when called within promise's.then().Refs: #34512
cc @nodejs/async_hooks
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes