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: introduce mandatory store argument in AsyncLocalStorage run methods #31930

Closed

Conversation

puzpuzpuz
Copy link
Member

@puzpuzpuz puzpuzpuz commented Feb 24, 2020

This PR introduces store as the first argument in AsyncLocalStorage's .run*() methods. The change is motivated by the following expectation: most users are going to use a custom object
as the store and an extra Map created by the old implementation is an overhead for their use case.

Important note. This is a backwards incompatible change. But as AsyncLocalStorage API has just landed into master (9c70292), it should be OK.

This PR implements the most simple (and as I believe, the most convenient for users) option from this discussion thread: #26540 (comment)

cc @vdeturckheim, @Qard, @Flarna

API change

Both run methods now have .run*(store, callback[, ..args]) signature instead of the old .run*(callback[, ..args]). For users who want to use a Map this change simply means

asyncLocalStorage.run(new Map(), () => /* ... */)

call instead of

asyncLocalStorage.run(() => /* ... */)
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • 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 Feb 24, 2020
@vdeturckheim
Copy link
Member

@nodejs/tsc this is a breaking change but for something that has not been shipped in any release yet. I don't think we have anything in the processes for this case. Do we need an extra step to land this?

@vdeturckheim vdeturckheim self-assigned this Feb 24, 2020
@nodejs-github-bot
Copy link
Collaborator

@targos
Copy link
Member

targos commented Feb 24, 2020

@nodejs/tsc this is a breaking change but for something that has not been shipped in any release yet. I don't think we have anything in the processes for this case. Do we need an extra step to land this?

I added backport-blocked label to #26540 so it doesn't land in a release before this change.
In general, breaking changes to experimental features can land in any release, as long as we document them.

@vdeturckheim
Copy link
Member

thanks @targos ! I will merge this in 48 (well 44) hours then :D

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm, definitely better

@vdeturckheim vdeturckheim removed their assignment Feb 24, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@puzpuzpuz
Copy link
Member Author

Many thanks for your code reviews, guys!

@nodejs-github-bot
Copy link
Collaborator

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

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

@vdeturckheim
Copy link
Member

@puzpuzpuz The title of the commit is longer than 72 columns and therefore does not follow the commit message guidelines can you please ammend it?

This commit introduces store as the first argument in
AsyncLocalStorage's run methods. The change is motivated by the
following expectation: most users are going to use a custom object
as the store and an extra Map created by the previous implementation
is an overhead for their use case.

Important note. This is a backwards incompatible change.
@puzpuzpuz
Copy link
Member Author

@vdeturckheim

@puzpuzpuz The title of the commit is longer than 72 columns and therefore does not follow the commit message guidelines can you please ammend it?

Thanks for pointing this out. Should be fixed now.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs nodejs deleted a comment from nodejs-github-bot Feb 26, 2020
@nodejs nodejs deleted a comment from nodejs-github-bot Feb 26, 2020
@nodejs-github-bot
Copy link
Collaborator

@vdeturckheim
Copy link
Member

CI seems constantly blocked on something that is not related to this PR :/

@nodejs-github-bot
Copy link
Collaborator

@vdeturckheim
Copy link
Member

vdeturckheim commented Feb 26, 2020

For some reason node-test-linux-linked-debug does not start when I restart the build. however, I restarted it standalone, it passes https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu1804_sharedlibs_debug_x64/18302/

This is ready to merge.
It's a bit late here and I'm travelling tomorrow, feel free to land it otherwise I'll do it on Friday.

@mhdawson
Copy link
Member

Last CI run does look good, will land.

mhdawson pushed a commit that referenced this pull request Feb 27, 2020
This commit introduces store as the first argument in
AsyncLocalStorage's run methods. The change is motivated by the
following expectation: most users are going to use a custom object
as the store and an extra Map created by the previous implementation
is an overhead for their use case.

Important note. This is a backwards incompatible change.
It was discussed and agreed an incompatible change is ok
since the API is still experimental and the modified
methods were only added within the last week so usage
will be minimal to none.

PR-URL: #31930
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@mhdawson
Copy link
Member

mhdawson commented Feb 27, 2020

Landed as 6510a74

@nodejs/tsc FYI that this has not been marked as SemVer major due to the following rational agreed in the PR and documented in the commit message: Important note. This is a backwards incompatible change. It was discussed and agreed an incompatible change is ok since the API is still experimental and the modified methods were only added within the last week so usage will be minimal to none.

@mhdawson mhdawson closed this Feb 27, 2020
@vdeturckheim
Copy link
Member

Thanks @mhdawson !

codebytere pushed a commit that referenced this pull request Feb 27, 2020
This commit introduces store as the first argument in
AsyncLocalStorage's run methods. The change is motivated by the
following expectation: most users are going to use a custom object
as the store and an extra Map created by the previous implementation
is an overhead for their use case.

Important note. This is a backwards incompatible change.
It was discussed and agreed an incompatible change is ok
since the API is still experimental and the modified
methods were only added within the last week so usage
will be minimal to none.

PR-URL: #31930
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@puzpuzpuz puzpuzpuz deleted the async-storage-custom-store branch February 28, 2020 06:47
@codebytere codebytere mentioned this pull request Feb 29, 2020
@codebytere
Copy link
Member

Blocked on #32131.

@puzpuzpuz
Copy link
Member Author

v12 backport: #32318

puzpuzpuz added a commit to puzpuzpuz/node that referenced this pull request Apr 14, 2020
This commit introduces store as the first argument in
AsyncLocalStorage's run methods. The change is motivated by the
following expectation: most users are going to use a custom object
as the store and an extra Map created by the previous implementation
is an overhead for their use case.

Important note. This is a backwards incompatible change.
It was discussed and agreed an incompatible change is ok
since the API is still experimental and the modified
methods were only added within the last week so usage
will be minimal to none.

PR-URL: nodejs#31930
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
This commit introduces store as the first argument in
AsyncLocalStorage's run methods. The change is motivated by the
following expectation: most users are going to use a custom object
as the store and an extra Map created by the previous implementation
is an overhead for their use case.

Important note. This is a backwards incompatible change.
It was discussed and agreed an incompatible change is ok
since the API is still experimental and the modified
methods were only added within the last week so usage
will be minimal to none.

PR-URL: nodejs#31930
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
targos pushed a commit that referenced this pull request Apr 28, 2020
This commit introduces store as the first argument in
AsyncLocalStorage's run methods. The change is motivated by the
following expectation: most users are going to use a custom object
as the store and an extra Map created by the previous implementation
is an overhead for their use case.

Important note. This is a backwards incompatible change.
It was discussed and agreed an incompatible change is ok
since the API is still experimental and the modified
methods were only added within the last week so usage
will be minimal to none.

PR-URL: #31930
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.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.

9 participants