Fatal Error in V8 Debugging Context on Node.js v23.7.0
Version
23.7.0
Platform
Darwin Apples-MacBook-Pro.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000 arm64
Subsystem
No response
What steps will reproduce the bug?
- Run a script that involves debugging, breakpoints, or function scope evaluation
- Observe the crash with the fatal error
How often does it reproduce? Is there a required condition?
The issue reproduces consistently when running a script that involves debugging, particularly with breakpoints, function scope evaluation, or closures.
What is the expected behavior? Why is that the expected behavior?
The debugger should pause execution at the debugger; statement and allow the user to inspect variables within the function's scope without causing a crash or becoming unresponsive.
What do you see instead?
I encountered a fatal error while running Node.js v23.7.0, leading to a crash with the following message:
Fatal error in , line 0
Check failed: needs_context && current_scope_ == closure_scope_ && current_scope_->is_function_scope() && !function_.is_null() implies function_->context() != *context_.
Additional information
Complete Error log trace if required
Fatal error in , line 0
Check failed: needs_context && current_scope_ == closure_scope_ && current_scope_->is_function_scope() && !function_.is_null() implies function_->context() != *context_.
#FailureMessage Object: 0x16bc90698 ----- Native stack trace -----
1: 0x1044899ac node::NodePlatform::GetStackTracePrinter()::$_0::__invoke() [/opt/homebrew/Cellar/node/23.6.1/bin/node]
2: 0x104f00f88 V8_Fatal(char const*, ...) [/opt/homebrew/Cellar/node/23.6.1/bin/node]
3: 0x1046b264c v8::internal::ScopeIterator::start_position() [/opt/homebrew/Cellar/node/23.6.1/bin/node]
4: 0x1046b2fec v8::internal::ScopeIterator::VisitLocalScope(std::__1::function<bool (v8::internal::Handlev8::internal::String, v8::internal::Handlev8::internal::Object, v8::internal::ScopeIterator::ScopeType)> const&, v8::internal::ScopeIterator::Mode, v8::internal::ScopeIterator::ScopeType) const [/opt/homebrew/Cellar/node/23.6.1/bin/node]
5: 0x1046b254c v8::internal::ScopeIterator::ScopeObject(v8::internal::ScopeIterator::Mode) [/opt/homebrew/Cellar/node/23.6.1/bin/node]
6: 0x104aa2fb0 v8_inspector::V8DebuggerAgentImpl::currentCallFrames(std::__1::unique_ptr<std::__1::vector<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>, std::__1::allocator<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>>>, std::__1::default_delete<std::__1::vector<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>, std::__1::allocator<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>>>>>) [/opt/homebrew/Cellar/node/23.6.1/bin/node]
7: 0x104aa280c v8_inspector::V8DebuggerAgentImpl::didPause(int, v8::Localv8::Value, std::__1::vector<int, std::__1::allocator
Needs actual steps to reproduce (current one is too vague/imprecise) and please try with official node binaries, not homebrew's.
I ran into this when I was working on the HTTP proxy support in builtins, though unfortunately I forgot to record the breakpoints in time before I switched to work on something else. I am fairly certain that it appeared when I was stepping into a breakpoint in either _http_client.js or _http_agent.js when I was running a test added in https://github.com/joyeecheung/node/tree/http-agent-proxy-3 , likely somewhere around https://github.com/nodejs/node/blob/7a40aa75a58047076da80ae16955c89cdf58de78/lib/_http_client.js#L771 and when I was stepping through a statement in either that function or somewhere related - it appears the debug scope chain that v8 maintains is either incomplete or gets GC-ed during the stepping.
I'm seeing this in my CI pipelines causing intermittent failures:
#
# Fatal error in , line 0
# unreachable code
#
#
#
#FailureMessage Object: 0x7f1c6bff78f0
----- Native stack trace -----
1: 0x101c1a1 [node (vitest)]
2: 0x27bb9eb V8_Fatal(char const*, ...) [node (vitest)]
3: 0x18f653c int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [node (vitest)]
4: 0x18f7271 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [node (vitest)]
5: 0x18f7536 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [node (vitest)]
6: 0x18f65be int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [node (vitest)]
7: 0x18f7271 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [node (vitest)]
8: 0x18f7536 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [node (vitest)]
9: 0x18f65be int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [node (vitest)]
10: 0x18f7271 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [node (vitest)]
11: 0x18f7536 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [node (vitest)]
12: 0x18f65be int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [node (vitest)]
13: 0x18f7271 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [node (vitest)]
14: 0x18f7536 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [node (vitest)]
15: 0x18f65be int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [node (vitest)]
16: 0x18f7271 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [node (vitest)]
17: 0x18f7536 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [node (vitest)]
18: 0x18f65be int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [node (vitest)]
19: 0x18f7271 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [node (vitest)]
20: 0x18f7536 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [node (vitest)]
21: 0x18f65be int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHeapObject>(unsigned char, v8::internal::SlotAccessorForHeapObject) [node (vitest)]
22: 0x18f7271 v8::internal::Deserializer<v8::internal::Isolate>::ReadData(v8::internal::Handle<v8::internal::HeapObject>, int, int) [node (vitest)]
23: 0x18f7536 v8::internal::Deserializer<v8::internal::Isolate>::ReadObject(v8::internal::SnapshotSpace) [node (vitest)]
24: 0x18f7806 int v8::internal::Deserializer<v8::internal::Isolate>::ReadSingleBytecodeData<v8::internal::SlotAccessorForHandle<v8::internal::Isolate> >(unsigned char, v8::internal::SlotAccessorForHandle<v8::internal::Isolate>) [node (vitest)]
25: 0x18f7fef v8::internal::Deserializer<v8::internal::Isolate>::ReadObject() [node (vitest)]
26: 0x18fd052 v8::internal::ObjectDeserializer::Deserialize() [node (vitest)]
27: 0x18fd234 v8::internal::ObjectDeserializer::DeserializeSharedFunctionInfo(v8::internal::Isolate*, v8::internal::SerializedCodeData const*, v8::internal::Handle<v8::internal::String>) [node (vitest)]
28: 0x18ef3d2 v8::internal::CodeSerializer::Deserialize(v8::internal::Isolate*, v8::internal::AlignedCachedData*, v8::internal::Handle<v8::internal::String>, v8::internal::ScriptDetails const&, v8::internal::MaybeHandle<v8::internal::Script>) [node (vitest)]
29: 0x13151bf [node (vitest)]
30: 0x1315490 v8::internal::Compiler::GetSharedFunctionInfoForScriptWithCachedData(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::ScriptDetails const&, v8::internal::AlignedCachedData*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason, v8::internal::NativesFlag, v8::ScriptCompiler::CompilationDetails*) [node (vitest)]
31: 0x1267517 v8::ScriptCompiler::CompileUnboundInternal(v8::Isolate*, v8::ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason) [node (vitest)]
32: 0xf7f513 node::contextify::ContextifyScript::New(v8::FunctionCallbackInfo<v8::Value> const&) [node (vitest)]
33: 0x12b4dca [node (vitest)]
34: 0x12b511a v8::internal::Builtin_HandleApiConstruct(int, unsigned long*, v8::internal::Isolate*) [node (vitest)]
35: 0x7f042be6c3b6
Trace/breakpoint trap
Just ran into this too, using v24.3.0 on WIndows 11
FWIW I saw a slightly different crash again when debugging https://github.com/nodejs/node/pull/58980. It might not be the same crash but I do have reproduction in https://github.com/joyeecheung/node/tree/http-agent-proxy-pr-crash
See repro and stacktrace
lldb -- out/Release/node --inspect-brk test/client-proxy/test-http-proxy-request-invalid-credentials.mjs
# Attach the Chrome devtools and keep stepping in the entry point file
(lldb) bt
* thread #1, name = 'MainThread', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffff)
* frame #0: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] long std::__1::__cxx_atomic_load[abi:nn190102]<long>(__a=<unavailable>, __order=relaxed) at cxx_atomic_impl.h:311:10 [opt]
frame #1: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] std::__1::__atomic_base<long, false>::load[abi:nn190102](this=<unavailable>, __m=relaxed) const volatile at atomic_base.h:55:12 [opt]
frame #2: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] long std::__1::atomic_load_explicit[abi:nn190102]<long>(__o=<unavailable>, __m=relaxed) at atomic.h:327:15 [opt]
frame #3: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] v8::base::Relaxed_Load(ptr=<unavailable>) at atomicops.h:347:10 [opt]
frame #4: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] unsigned long v8::base::AsAtomicImpl<long>::Relaxed_Load<unsigned long>(addr=<unavailable>) at atomic-utils.h:88:9 [opt]
frame #5: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] v8::internal::TaggedField<v8::internal::MapWord, 0, v8::internal::V8HeapCompressionSchemeImpl<v8::internal::MainCage>>::Relaxed_Load_Map_Word(cage_base=<unavailable>, host=Tagged<v8::internal::HeapObject> @ x8) at tagged-field-inl.h:281:26 [opt]
frame #6: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] v8::internal::HeapObject::map_word(this=<unavailable>, cage_base=<unavailable>, tag=<unavailable>) const at objects-inl.h:1542:10 [opt]
frame #7: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] v8::internal::HeapObject::map(this=<unavailable>, cage_base=<unavailable>) const at objects-inl.h:1349:10 [opt]
frame #8: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] v8::internal::HeapObject::map(this=<unavailable>) const at objects-inl.h:1345:22 [opt]
frame #9: 0x00000001006eef4c node`v8::internal::Context::module() const [inlined] v8::internal::Context::IsModuleContext(this=<unavailable>) const at contexts-inl.h:196:10 [opt]
frame #10: 0x00000001006eef4c node`v8::internal::Context::module(this=0x000000016fdfcaa8) const at contexts.cc:184:20 [opt]
frame #11: 0x000000010043ac1c node`v8::internal::ScopeIterator::VisitLocals(this=0x00006000021f41c8, visitor=0x000000016fdfcb98, mode=ALL, scope_type=ScopeTypeModule) const at debug-scopes.cc:970:57 [opt]
frame #12: 0x00000001004394b0 node`v8::internal::ScopeIterator::VisitLocalScope(this=0x00006000021f41c8, visitor=0x000000016fdfcb98, mode=ALL, scope_type=ScopeTypeModule) const at debug-scopes.cc:998:9 [opt]
frame #13: 0x0000000100438ae4 node`v8::internal::ScopeIterator::DeclaresLocals(this=0x00006000021f41c8, mode=ALL) const at debug-scopes.cc:429:3 [opt]
frame #14: 0x0000000100436bc8 node`v8::internal::DebugScopeIterator::Advance() [inlined] v8::internal::DebugScopeIterator::ShouldIgnore(this=0x00006000021f41c0) at debug-scope-iterator.cc:75:21 [opt]
frame #15: 0x0000000100436bac node`v8::internal::DebugScopeIterator::Advance(this=0x00006000021f41c0) at debug-scope-iterator.cc:68:21 [opt]
frame #16: 0x0000000100a6c978 node`v8_inspector::V8DebuggerAgentImpl::currentCallFrames(std::__1::unique_ptr<std::__1::vector<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>, std::__1::allocator<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>>>, std::__1::default_delete<std::__1::vector<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>, std::__1::allocator<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>>>>>*) [inlined] v8_inspector::(anonymous namespace)::buildScopes(isolate=0x0000000140008000, iterator=0x00006000021f41c0, injectedScript=<unavailable>, scopes=<unavailable>) at v8-debugger-agent-impl.cc:348:39 [opt]
frame #17: 0x0000000100a6c968 node`v8_inspector::V8DebuggerAgentImpl::currentCallFrames(this=<unavailable>, result=<unavailable>) at v8-debugger-agent-impl.cc:1796:9 [opt]
frame #18: 0x0000000100a6335c node`v8_inspector::V8DebuggerAgentImpl::didPause(this=<unavailable>, contextId=<unavailable>, exception=<unavailable>, hitBreakpoints=<unavailable>, exceptionType=<unavailable>, isUncaught=<unavailable>, breakReasons=<unavailable>) at v8-debugger-agent-impl.cc:2279:23 [opt]
frame #19: 0x0000000100a83efc node`v8_inspector::V8InspectorImpl::forEachSession(int, std::__1::function<void (v8_inspector::V8InspectorSessionImpl*)> const&) [inlined] std::__1::__function::__value_func<void (v8_inspector::V8InspectorSessionImpl*)>::operator()[abi:nn190102](this=0x000000016fdfd028, __args=<unavailable>) const at function.h:430:12 [opt]
frame #20: 0x0000000100a83ee4 node`v8_inspector::V8InspectorImpl::forEachSession(int, std::__1::function<void (v8_inspector::V8InspectorSessionImpl*)> const&) [inlined] std::__1::function<void (v8_inspector::V8InspectorSessionImpl*)>::operator()(this=0x000000016fdfd028, __arg=0x00006000033ec000) const at function.h:989:10 [opt]
frame #21: 0x0000000100a83ee4 node`v8_inspector::V8InspectorImpl::forEachSession(this=0x000000013d80a5a0, contextGroupId=1, callback=0x000000016fdfd028) at v8-inspector-impl.cc:451:40 [opt]
frame #22: 0x0000000100a75b28 node`v8_inspector::V8Debugger::handleProgramBreak(this=0x000000013d80a720, pausedContext=Local<v8::Context> @ 0x000000016fdfd020, exception=Local<v8::Value> @ 0x000000016fdfd018, breakpointIds=<unavailable>, breakReasons=(bits_ = 2), exceptionType=<unavailable>, isUncaught=<unavailable>) at v8-debugger.cc:532:16 [opt]
frame #23: 0x000000010043fe14 node`v8::internal::Debug::OnDebugBreak(this=0x00006000035e0000, break_points_hit=<unavailable>, lastStepAction=<unavailable>, break_reasons=<unavailable>) at debug.cc:2640:22 [opt]
frame #24: 0x000000010043f474 node`v8::internal::Debug::Break(this=0x00006000035e0000, frame=<unavailable>, break_target=<unavailable>) at debug.cc:802:5 [opt]
frame #25: 0x00000001009c1f50 node`v8::internal::Runtime_DebugBreakOnBytecode(int, unsigned long*, v8::internal::Isolate*) [inlined] v8::internal::__RT_impl_Runtime_DebugBreakOnBytecode(args=<unavailable>, isolate=0x0000000140008000) at runtime-debug.cc:53:23 [opt]
frame #26: 0x00000001009c1eb0 node`v8::internal::Runtime_DebugBreakOnBytecode(args_length=<unavailable>, args_object=<unavailable>, isolate=0x0000000140008000) at runtime-debug.cc:35:1 [opt]
frame #27: 0x0000000101018234 node`Builtins_CEntry_Return2_ArgvOnStack_NoBuiltinExit + 84
frame #28: 0x00000001010f6508 node`Builtins_DebugBreak3Handler + 72
frame #29: 0x0000000100f7912c node`Builtins_InterpreterEntryTrampoline + 268
frame #30: 0x0000000100fba168 node`Builtins_GeneratorPrototypeNext + 136
frame #31: 0x0000000100f768cc node`Builtins_JSEntryTrampoline + 172
frame #32: 0x0000000100f76570 node`Builtins_JSEntry + 176
frame #33: 0x00000001004aa4a8 node`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [inlined] v8::internal::GeneratedCode<unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, long, unsigned long**>::Call(this=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>, args=<unavailable>) at simulator.h:212:12 [opt]
frame #34: 0x00000001004aa4a4 node`v8::internal::(anonymous namespace)::Invoke(isolate=0x0000000140008000, params=0x000000016fdfd828) at execution.cc:440:22 [opt]
frame #35: 0x00000001004aacd8 node`v8::internal::(anonymous namespace)::InvokeWithTryCatch(isolate=0x0000000140008000, params=0x000000016fdfd828) at execution.cc:500:18 [opt]
frame #36: 0x00000001004aada4 node`v8::internal::Execution::TryCall(isolate=<unavailable>, callable=<unavailable>, receiver=<unavailable>, args=<unavailable>, message_handling=<unavailable>, exception_out=<unavailable>) at execution.cc:596:10 [opt]
frame #37: 0x00000001008bd678 node`v8::internal::SourceTextModule::ExecuteModule(isolate=0x0000000140008000, module=<unavailable>, exception_out=0x000000016fdfd8c8) at source-text-module.cc:1147:8 [opt]
frame #38: 0x00000001008bcfa4 node`v8::internal::SourceTextModule::InnerModuleEvaluation(isolate=0x0000000140008000, module=Handle<v8::internal::SourceTextModule> @ x21, stack=<unavailable>, dfs_index=0x000000016fdfd97c) at source-text-module.cc:1328:10 [opt]
frame #39: 0x00000001008bc9a8 node`v8::internal::SourceTextModule::Evaluate(isolate=0x0000000140008000, module=Handle<v8::internal::SourceTextModule> @ x21) at source-text-module.cc:856:7 [opt]
frame #40: 0x0000000100871724 node`v8::internal::Module::Evaluate(isolate=0x0000000140008000, module=Handle<v8::internal::Module> @ x20) at module.cc:318:12 [opt]
frame #41: 0x0000000100309a94 node`v8::Module::Evaluate(this=0x000000013d028a60, context=<unavailable>) at api.cc:2275:28 [opt]
frame #42: 0x00000001000d3270 node`node::loader::ModuleWrap::Evaluate(v8::FunctionCallbackInfo<v8::Value> const&) [inlined] node::loader::ModuleWrap::Evaluate(v8::FunctionCallbackInfo<v8::Value> const&)::$_0::operator()(this=<unavailable>) const at module_wrap.cc:649:40 [opt]
frame #43: 0x00000001000d3264 node`node::loader::ModuleWrap::Evaluate(args=0x000000016fdfe148) at module_wrap.cc:665:14 [opt]
frame #44: 0x0000000100f7ad58 node`Builtins_CallApiCallbackGeneric + 152
frame #45: 0x0000000100f7912c node`Builtins_InterpreterEntryTrampoline + 268
frame #46: 0x0000000100fb7ac8 node`Builtins_AsyncFunctionAwaitResolveClosure + 72
frame #47: 0x000000010108ebd8 node`Builtins_PromiseFulfillReactionJob + 56
frame #48: 0x0000000100fa6ef0 node`Builtins_RunMicrotasks + 560
frame #49: 0x0000000100f767b0 node`Builtins_JSRunMicrotasksEntry + 176
frame #50: 0x00000001004aa460 node`v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [inlined] v8::internal::GeneratedCode<unsigned long, unsigned long, v8::internal::MicrotaskQueue*>::Call(this=<unavailable>, args=<unavailable>, args=<unavailable>) at simulator.h:212:12 [opt]
frame #51: 0x00000001004aa45c node`v8::internal::(anonymous namespace)::Invoke(isolate=0x0000000140008000, params=0x000000016fdfe618) at execution.cc:458:41 [opt]
frame #52: 0x00000001004aacd8 node`v8::internal::(anonymous namespace)::InvokeWithTryCatch(isolate=0x0000000140008000, params=0x000000016fdfe618) at execution.cc:500:18 [opt]
frame #53: 0x00000001004aae14 node`v8::internal::Execution::TryRunMicrotasks(isolate=<unavailable>, microtask_queue=<unavailable>) at execution.cc:604:10 [opt]
frame #54: 0x00000001004d8e5c node`v8::internal::MicrotaskQueue::RunMicrotasks(this=0x00006000038ec510, isolate=0x0000000140008000) at microtask-queue.cc:185:22 [opt]
frame #55: 0x00000001004d977c node`v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [inlined] v8::internal::MicrotaskQueue::PerformCheckpointInternal(this=0x00006000038ec510, v8_isolate=0x0000000140008000) at microtask-queue.cc:129:3 [opt]
frame #56: 0x00000001004d9740 node`v8::internal::MicrotaskQueue::PerformCheckpoint(this=0x00006000038ec510, isolate=0x0000000140008000) at microtask-queue.h:48:5 [opt]
frame #57: 0x0000000100027eb4 node`node::InternalCallbackScope::Close(this=0x000000016fdfe8b0) at callback.cc:147:35 [opt]
frame #58: 0x0000000100027980 node`node::InternalCallbackScope::~InternalCallbackScope() [inlined] node::InternalCallbackScope::~InternalCallbackScope(this=0x000000016fdfe8b0) at callback.cc:99:3 [opt]
frame #59: 0x000000010002797c node`node::InternalCallbackScope::~InternalCallbackScope(this=0x000000016fdfe8b0) at callback.cc:98:49 [opt]
frame #60: 0x00000001000d99d0 node`node::StartExecution(env=<unavailable>, cb=<unavailable>) at node.cc:405:1 [opt]
frame #61: 0x000000010002c940 node`node::LoadEnvironment(env=0x000000013d048200, cb=<unavailable>, preload=<unavailable>) at environment.cc:539:10 [opt]
frame #62: 0x000000010017024c node`node::NodeMainInstance::Run() [inlined] node::NodeMainInstance::Run(this=<unavailable>, exit_code=<unavailable>, env=0x000000013d048200) at node_main_instance.cc:106:7 [opt]
frame #63: 0x000000010017021c node`node::NodeMainInstance::Run(this=<unavailable>) at node_main_instance.cc:99:3 [opt]
frame #64: 0x00000001000dd8ec node`node::Start(int, char**) [inlined] node::StartInternal(argc=<unavailable>, argv=<unavailable>) at node.cc:1540:24 [opt]
frame #65: 0x00000001000dd860 node`node::Start(argc=<unavailable>, argv=<unavailable>) at node.cc:1547:27 [opt]
frame #66: 0x000000019e34eb4c dyld`start + 6000
This error might be fixed by the following change. https://chromium-review.googlesource.com/c/v8/v8/+/6507402
Same issue for 24.6.0
#
# Fatal error in , line 0
# Check failed: needs_context && current_scope_ == closure_scope_ && current_scope_->is_function_scope() && !function_.is_null() implies function_->context() != *context_.
#
#
#
#FailureMessage Object: 0x16dca7918
----- Native stack trace -----
1: 0x1022e8af4 node::NodePlatform::GetStackTracePrinter()::$_0::__invoke() [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
2: 0x103b1561c V8_Fatal(char const*, ...) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
3: 0x102578ec8 v8::internal::ScopeIterator::VisitLocalScope(std::__1::function<bool (v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::Object>, v8::internal::ScopeIterator::ScopeType)> const&, v8::internal::ScopeIterator::Mode, v8::internal::ScopeIterator::ScopeType) const [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
4: 0x102577f1c v8::internal::ScopeIterator::ScopeObject(v8::internal::ScopeIterator::Mode) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
5: 0x102bb2a5c v8_inspector::V8DebuggerAgentImpl::currentCallFrames(std::__1::unique_ptr<std::__1::vector<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>, std::__1::allocator<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>>>, std::__1::default_delete<std::__1::vector<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>, std::__1::allocator<std::__1::unique_ptr<v8_inspector::protocol::Debugger::CallFrame, std::__1::default_delete<v8_inspector::protocol::Debugger::CallFrame>>>>>>*) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
6: 0x102ba8e28 v8_inspector::V8DebuggerAgentImpl::didPause(int, v8::Local<v8::Value>, std::__1::vector<int, std::__1::allocator<int>> const&, v8::debug::ExceptionType, bool, v8::base::EnumSet<v8::debug::BreakReason, int>) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
7: 0x102bcb5f8 v8_inspector::V8InspectorImpl::forEachSession(int, std::__1::function<void (v8_inspector::V8InspectorSessionImpl*)> const&) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
8: 0x102bbc6d0 v8_inspector::V8Debugger::handleProgramBreak(v8::Local<v8::Context>, v8::Local<v8::Value>, std::__1::vector<int, std::__1::allocator<int>> const&, v8::base::EnumSet<v8::debug::BreakReason, int>, v8::debug::ExceptionType, bool) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
9: 0x10257f64c v8::internal::Debug::OnDebugBreak(v8::internal::DirectHandle<v8::internal::FixedArray>, v8::internal::StepAction, v8::base::EnumSet<v8::debug::BreakReason, int>) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
10: 0x10257ebc8 v8::internal::Debug::Break(v8::internal::JavaScriptFrame*, v8::internal::DirectHandle<v8::internal::JSFunction>) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
11: 0x102b00f3c v8::internal::Runtime_DebugBreakOnBytecode(int, unsigned long*, v8::internal::Isolate*) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
12: 0x10315e1f4 Builtins_CEntry_Return2_ArgvOnStack_NoBuiltinExit [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
13: 0x10323b708 Builtins_DebugBreak3Handler [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
14: 0x1030c0bec Builtins_InterpreterEntryTrampoline [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
15: 0x1030c0bec Builtins_InterpreterEntryTrampoline [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
16: 0x1030ff648 Builtins_AsyncFunctionAwaitResolveClosure [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
17: 0x1031d45f8 Builtins_PromiseFulfillReactionJob [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
18: 0x1030eea50 Builtins_RunMicrotasks [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
19: 0x1030be7b0 Builtins_JSRunMicrotasksEntry [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
20: 0x1025e8798 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
21: 0x1025e900c v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
22: 0x1025e9148 v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
23: 0x10261804c v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
24: 0x1026189ac v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
25: 0x102150f4c node::InternalCallbackScope::Close() [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
26: 0x1021509c4 node::CallbackScope::~CallbackScope() [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
27: 0x102218c40 napi_close_callback_scope [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
28: 0x13655467c zmq::Socket::Poller::ReadableCallback() [/Users/haiodo/Develop/private/platform/common/temp/node_modules/.pnpm/[email protected]/node_modules/zeromq/build/darwin/arm64/node/libc-115-Release/addon.node]
29: 0x13655a0a4 zmq::Poller<zmq::Socket::Poller>::TriggerReadable() [/Users/haiodo/Develop/private/platform/common/temp/node_modules/.pnpm/[email protected]/node_modules/zeromq/build/darwin/arm64/node/libc-115-Release/addon.node]
30: 0x13655b010 zmq::Poller<zmq::Socket::Poller>::Callback(uv_poll_s*, int, int) [/Users/haiodo/Develop/private/platform/common/temp/node_modules/.pnpm/[email protected]/node_modules/zeromq/build/darwin/arm64/node/libc-115-Release/addon.node]
31: 0x1030b0cec uv__io_poll [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
32: 0x10309d09c uv_run [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
33: 0x102151a78 node::SpinEventLoopInternal(node::Environment*) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
34: 0x1022ae6ac node::NodeMainInstance::Run() [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
35: 0x1022149ec node::Start(int, char**) [/Users/haiodo/.nvm/versions/node/v24.6.0/bin/node]
36: 0x1886beb98 start [/usr/lib/dyld]
[1] 66186 trace trap /usr/bin/env /Users/haiodo/.nvm/versions/node/v24.6.0/bin/node -c -t
same for 24.8.0
I'm getting the same issue on node 24.2.0 on Mac. It reproduces consistently when stepping over a loop with async calls: for await (const es of dataSeq) {...}
I have this trying to iterate over a Map in Node v24.11.0.
Im inside docker with a command started with node --inspect-brk=0.0.0.0 server/migrate.js and port 9229 mapped to the outside world. Dev tools is running on the outside
for (const mstable of mstables.entries()) {
...
}
This is all inside of an async function
I tried converting my map to an Array first
const tablearray = Array.from(mstables)
for(constmstable of tablearray) {
...
}
But that crashed too at the for loop. The conversion worked.
Finally i did
mstables.forEach(async mstable => {
---
});
That worked
The simple loop is also working:
for (let i=0;i<mstables.length;i++) {
const mstable = mstables[i];
}