Skip to content

Conversation

szegedi
Copy link
Contributor

@szegedi szegedi commented Apr 10, 2025

Adds a variant of node::AsyncHooksGetExecutionAsyncId that takes a v8::Local<v8::Context> and returns the async ID belonging to the node::Environment (if any) of that Context.

This is not dissimilar to how e.g. node::Environment::GetCurrent method also exists with overloads for both v8::Isolate* and v8::Local<v8::Context>.

In certain situations it would be useful to pass a Context object different from v8::Isolate::GetCurrentContext, e.g. the one returned by v8::Isolate::GetEnteredOrMicrotaskContext would be useful in recording the async ID in a V8 GC prologue callback when current context is not set.

szegedi added 2 commits April 10, 2025 14:38
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Apr 10, 2025
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.23%. Comparing base (9bbbe60) to head (138ff38).
Report is 48 commits behind head on main.

Files with missing lines Patch % Lines
src/api/hooks.cc 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #57820   +/-   ##
=======================================
  Coverage   90.23%   90.23%           
=======================================
  Files         630      630           
  Lines      185481   185470   -11     
  Branches    36373    36371    -2     
=======================================
- Hits       167375   167368    -7     
- Misses      10994    10998    +4     
+ Partials     7112     7104    -8     
Files with missing lines Coverage Δ
src/node.h 92.15% <ø> (ø)
src/api/hooks.cc 84.39% <80.00%> (-0.17%) ⬇️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 10, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 10, 2025
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@Flarna Flarna added semver-minor PRs that contain new features and should be released in the next minor version. async_hooks Issues and PRs related to the async hooks subsystem. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. commit-queue Add this label to land a pull request using GitHub Actions. labels Apr 17, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 17, 2025
@nodejs-github-bot nodejs-github-bot merged commit ffb9bfb into nodejs:main Apr 17, 2025
71 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in ffb9bfb

RafaelGSS pushed a commit that referenced this pull request May 1, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
RafaelGSS pushed a commit that referenced this pull request May 2, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 pushed a commit that referenced this pull request May 6, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 pushed a commit that referenced this pull request May 6, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
@szegedi szegedi deleted the szegedi/async-id-any-context branch May 8, 2025 07:19
RafaelGSS pushed a commit that referenced this pull request May 14, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 pushed a commit that referenced this pull request May 16, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 pushed a commit that referenced this pull request May 17, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 pushed a commit that referenced this pull request May 18, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
nodejs-github-bot added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
aduh95 pushed a commit that referenced this pull request May 19, 2025
Adds a variant of AsyncHooksGetExecutionAsyncId that takes a V8 Context
and returns the async ID belonging to the Environment (if any) of that
Context. Sometimes we want to use Isolate::GetEnteredOrMicrotaskContext
insteads of Isolate::GetCurrentContext (e.g. recording the async ID in
a V8 GC prologue callback) when current context is not set.

PR-URL: #57820
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
aduh95 added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: TODO
aduh95 added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
aduh95 added a commit that referenced this pull request May 19, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
aduh95 added a commit to aduh95/node that referenced this pull request May 20, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) nodejs#57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) nodejs#58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) nodejs#57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) nodejs#58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) nodejs#57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) nodejs#57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) nodejs#57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) nodejs#57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) nodejs#57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) nodejs#57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) nodejs#57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) nodejs#57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) nodejs#57888

PR-URL: nodejs#58388
aduh95 added a commit that referenced this pull request May 21, 2025
Notable changes:

deps:
  * update timezone to 2025b (Node.js GitHub Bot) #57857
doc:
  * add dario-piotrowicz to collaborators (Dario Piotrowicz) #58102
  * (SEMVER-MINOR) graduate multiple experimental apis (James M Snell) #57765
esm:
  * (SEMVER-MINOR) graduate import.meta properties (James M Snell) #58011
  * (SEMVER-MINOR) support top-level Wasm without package type (Guy Bedford) #57610
sqlite:
  * (SEMVER-MINOR) add StatementSync.prototype.columns() (Colin Ihrig) #57490
src:
  * (SEMVER-MINOR) set default config as `node.config.json` (Marco Ippolito) #57171
  * (SEMVER-MINOR) create `THROW_ERR_OPTIONS_BEFORE_BOOTSTRAPPING` (Marco Ippolito) #57016
  * (SEMVER-MINOR) add config file support (Marco Ippolito) #57016
  * (SEMVER-MINOR) add ExecutionAsyncId getter for any Context (Attila Szegedi) #57820
stream:
  * (SEMVER-MINOR) preserve AsyncLocalStorage context in finished() (Gürgün Dayıoğlu) #57865
util:
  * (SEMVER-MINOR) add `types.isFloat16Array()` (Livia Medeiros) #57879
worker:
  * (SEMVER-MINOR) add worker.getHeapStatistics() (Matteo Collina) #57888

PR-URL: #58388
@ghost ghost mentioned this pull request Jun 8, 2025
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. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants