Skip to content

inspector: prevent propagation of promise hooks to noPromise hooks #58841

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

islandryu
Copy link
Member

@islandryu islandryu commented Jun 26, 2025

This fix is intended to address a crash that occurs when inspecting code using async hooks with a debug build.

It resolves an issue where Promise hook events were incorrectly propagating to noPromiseHook.

reproduction

The issue can be reproduced using the added test case.
Alternatively, you can reproduce it by debugging code that uses async hooks with Chrome Inspector.
Since it's caused by a debug check failure, it only occurs in debug builds.

The error message is as follows:

#
# Fatal error in ../../deps/v8/src/inspector/v8-debugger.cc, line 1289
# Debug check failed: m_currentTasks.back() == task.
#
#
#
#FailureMessage Object: 0x16fdfd758
----- Native stack trace -----

 1: 0x10012d4f0 node::DumpNativeBacktrace(__sFILE*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 2: 0x1003c9260 node::NodePlatform::GetStackTracePrinter()::$_0::operator()() const [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 3: 0x1003c921c node::NodePlatform::GetStackTracePrinter()::$_0::__invoke() [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 4: 0x102e74918 V8_Fatal(char const*, int, char const*, ...) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 5: 0x102e74288 v8::base::SetFatalFunction(void (*)(char const*, int, char const*)) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 6: 0x101543094 v8_inspector::V8Debugger::asyncTaskFinishedForStack(void*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 7: 0x100569efc node::inspector::NodeInspectorClient::AsyncTaskFinished(void*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 8: 0x100569ec0 node::inspector::Agent::AsyncTaskFinished(void*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
 9: 0x100597418 void node::inspector::(anonymous namespace)::InvokeAsyncTaskFnWithId<&node::inspector::Agent::AsyncTaskFinished(void*)>(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
10: 0x101f76298 Builtins_CallApiCallbackGeneric [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
11: 0x101f7466c Builtins_InterpreterEntryTrampoline [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
12: 0x101f7466c Builtins_InterpreterEntryTrampoline [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
13: 0x101f7466c Builtins_InterpreterEntryTrampoline [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
14: 0x101fa6398 Builtins_RunMicrotasks [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
15: 0x101f71590 Builtins_JSRunMicrotasksEntry [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
16: 0x100a533b4 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
17: 0x100a54bb4 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
18: 0x100a55244 v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
19: 0x100aaca68 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
20: 0x100aac718 v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
21: 0x10004d124 node::InternalCallbackScope::Close() [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
22: 0x10004cf00 node::InternalCallbackScope::~InternalCallbackScope() [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
23: 0x10004c89c node::InternalCallbackScope::~InternalCallbackScope() [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
24: 0x1001f7d90 node::StartExecution(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
25: 0x10005da38 node::LoadEnvironment(node::Environment*, std::__1::function<v8::MaybeLocal<v8::Value> (node::StartExecutionCallbackInfo const&)>, std::__1::function<void (node::Environment*, v8::Local<v8::Value>, v8::Local<v8::Value>)>) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
26: 0x1003342d8 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
27: 0x100333f64 node::NodeMainInstance::Run() [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
28: 0x1001fa9a4 node::StartInternal(int, char**) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
29: 0x1001fa5c0 node::Start(int, char**) [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
30: 0x10258fb64 main [/Users/shimaryuuhei/workspace/islandryu2/node/out/Debug/node]
31: 0x1818a8274 start [/usr/lib/dyld]

@nodejs-github-bot nodejs-github-bot added async_hooks Issues and PRs related to the async hooks subsystem. needs-ci PRs that need a full CI run. labels Jun 26, 2025
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.08%. Comparing base (a705e24) to head (be4d2b1).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #58841   +/-   ##
=======================================
  Coverage   90.08%   90.08%           
=======================================
  Files         640      640           
  Lines      188375   188454   +79     
  Branches    36939    36966   +27     
=======================================
+ Hits       169698   169772   +74     
- Misses      11397    11409   +12     
+ Partials     7280     7273    -7     
Files with missing lines Coverage Δ
lib/internal/async_hooks.js 99.37% <100.00%> (+<0.01%) ⬆️

... and 39 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.

@Flarna Flarna added the c++ Issues and PRs that require attention from people who are familiar with C++. label Jun 26, 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++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants