Skip to content

src: add ExecutionAsyncId getter for any Context - #57820

Merged
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
szegedi:szegedi/async-id-any-context
Apr 17, 2025
Merged

src: add ExecutionAsyncId getter for any Context#57820
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
szegedi:szegedi/async-id-any-context

Conversation

@szegedi

Copy link
Copy Markdown
Contributor

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.

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-botnodejs-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
Comment threadsrc/node.h Outdated
szegediand others added 2 commits April 10, 2025 16:17
Co-authored-by: Chengzhong Wu <legendecas@gmail.com>
@codecov

codecovBot commented Apr 10, 2025

Copy link
Copy Markdown

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 linesPatch %Lines
src/api/hooks.cc80.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 linesCoverage Δ
src/node.h92.15% <ø> (ø)
src/api/hooks.cc84.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.

@legendecaslegendecas added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 10, 2025
@github-actionsgithub-actionsBot 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
Copy Markdown
Collaborator

Comment threadsrc/api/hooks.cc
@FlarnaFlarna 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-botnodejs-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:mainApr 17, 2025
@nodejs-github-bot

Copy link
Copy Markdown
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
@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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
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 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
@ghostghost mentioned this pull request Jun 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

async_hooksIssues and PRs related to the async hooks subsystem.c++Issues and PRs that require attention from people who are familiar with C++.commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.needs-ciPRs that need a full CI run.semver-minorPRs 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

@szegedi@nodejs-github-bot@jasnell@legendecas@Flarna