Skip to content
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 context loss after nested calls to AsyncLocalStorage #32085

Conversation

puzpuzpuz
Copy link
Member

@puzpuzpuz puzpuzpuz commented Mar 4, 2020

Fixes the following issues within AsyncLocalStorage API:

  • Nested calls to run* were erasing the outer store, leading to context loss.
    • Note: test-async-local-storage-nested.js was updated to validate this fix, as its previous contents were a partial duplicate of test-async-local-storage-no-mix-contexts.js
  • Calls to exit* were switching enabled field to true without checking current value. This leads to incorrect behavior of further getStore and run* calls.

These issues were discussed in #31950, but as that PR involves significant changes in implementation and will require some time to settle down.

cc @vdeturckheim @Qard @Flarna

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the async_hooks Issues and PRs related to the async hooks subsystem. label Mar 4, 2020
@nodejs-github-bot
Copy link
Collaborator

@vdeturckheim
Copy link
Member

@puzpuzpuz I am afraid there is a curse on your PRs and CI 😝. I will resume this build 😉

@nodejs-github-bot
Copy link
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/29566/

@puzpuzpuz
Copy link
Member Author

@puzpuzpuz I am afraid there is a curse on your PRs and CI 😝. I will resume this build 😉

I knew it. Sounds like the most logical reason for these permanently flaky builds. 🤣

Thanks for restarting it.

@puzpuzpuz
Copy link
Member Author

Looks like the second attempt was successful. 🥳

@Qard Qard added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 6, 2020
Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mhdawson pushed a commit that referenced this pull request Mar 6, 2020
PR-URL: #32085
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@mhdawson
Copy link
Member

mhdawson commented Mar 6, 2020

Landed in 86ab4ee

@mhdawson mhdawson closed this Mar 6, 2020
@puzpuzpuz puzpuzpuz deleted the async-local-storage-fix-nested-calls branch March 7, 2020 06:05
MylesBorins pushed a commit that referenced this pull request Mar 9, 2020
PR-URL: #32085
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@MylesBorins MylesBorins mentioned this pull request Mar 10, 2020
@codebytere
Copy link
Member

Blocked on #26540.

@puzpuzpuz
Copy link
Member Author

v12 backport: #32318

puzpuzpuz added a commit to puzpuzpuz/node that referenced this pull request Apr 14, 2020
PR-URL: nodejs#32085
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@targos targos removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 25, 2020
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
PR-URL: nodejs#32085
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
targos pushed a commit that referenced this pull request Apr 28, 2020
PR-URL: #32085
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
async_hooks Issues and PRs related to the async hooks subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants