-
Notifications
You must be signed in to change notification settings - Fork 30k
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
async_hooks: fix id assignment in fast-path promise hook #34548
async_hooks: fix id assignment in fast-path promise hook #34548
Conversation
de142ac
to
61cf759
Compare
61cf759
to
c03a3ad
Compare
c03a3ad
to
2823ac3
Compare
@addaleax thanks for the helpful review! |
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
@addaleax thanks for sharing this workaround. I've added the duplicate |
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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
Landed in b7a2329 |
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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
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 <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
This PR fixes a bug introduced by #34512.
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 resultexecutionAsyncId
could return wrong id when called within promise's.then()
.Refs: #34512
cc @nodejs/async_hooks
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes