Skip to content

Terminating a worker while it evaluates the parent of a top-level-await module aborts the process #67550

Open

Description

@ronag

Version

v26.13.0, v24.15.0, v22.22.3

Platform

Darwin 25.6.0 arm64

Subsystem

esm, worker_threads

What steps will reproduce the bug?

tla.mjs:

await 0

parent.mjs:

import { parentPort } from 'node:worker_threads'
import './tla.mjs'

parentPort.postMessage('running')
const end = Date.now() + 5000
while (Date.now() < end);

main.mjs:

import { Worker } from 'node:worker_threads'
import { once } from 'node:events'

const worker = new Worker(new URL('./parent.mjs', import.meta.url))
await once(worker, 'message')
await worker.terminate()
console.log('terminated without crashing')

node main.mjs

How often does it reproduce? Is there a required condition?

Every time. parent.mjs has no top-level await, but it imports a module that does. So V8 runs parent.mjs's body from AsyncModuleExecutionFulfilled after tla.mjs settles, and the worker is terminated while that body is running. If you remove the await from tla.mjs, the worker terminates cleanly.

What is the expected behavior? Why is that the expected behavior?

worker.terminate() stops the worker, and main.mjs prints terminated without crashing.

What do you see instead?

#
# Fatal error in , line 0
# Check failed: !is_null().
#
----- Native stack trace -----

 1: node::NodePlatform::GetStackTracePrinter()::$_0::__invoke()
 2: V8_Fatal(char const*, ...)
 3: v8::internal::SourceTextModule::ExecuteAsyncModule(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::SourceTextModule>) (.cold.1)
 4: v8::internal::SourceTextModule::AsyncModuleExecutionFulfilled(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>)
 5: v8::internal::Builtin_CallAsyncModuleFulfilled(int, unsigned long*, v8::internal::Isolate*)
 6: Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit
 7: Builtins_PromiseFulfillReactionJob
 8: Builtins_RunMicrotasks
 ...
24: node::worker::Worker::Run()

The process exits with code 133. On v22 and v24 the message is Check failed: (location_) != nullptr.

Additional information

ExecuteModule fails with the termination exception and leaves exception empty. AsyncModuleExecutionFulfilled then calls exception.ToHandleChecked() on it. V8 fixed this in v8/v8@be84cdeee94e ("[d8] Handle termination exception in async modules"), which returns early when execution is terminating, and main has it through the V8 update. v22.x, v24.x and v26.x don't have it, so it needs a cherry-pick.

Probably the same crash as #53238 and #62114, both closed without a repro.

Activity

  1. ronag commented on Nov 17, 2026

    @ronag
    MemberAuthor
  2. mcollina commented on Nov 17, 2026

    @mcollina
    SponsorMember

    This is a V8 bug, not a Node.js one. The crash comes from SourceTextModule::AsyncModuleExecutionFulfilled calling exception.ToHandleChecked() on an empty handle when ExecuteModule fails with a termination exception (worker terminated mid-evaluation). The fix landed upstream in V8 commit be84cdeee94e ("[d8] Handle termination exception in async modules", 2026-03-11), which returns early when the isolate is execution-terminating.

    Node main already has this fix via the V8 roll (V8 15.6.75). The release lines v22.x, v24.x and v26.x do not, so we need to cherry-pick that V8 fix onto each branch and roll the deps/v8 submodule. I've also confirmed the crash reproduces on v24.21.0, so this can now get a regression test in test/parallel/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions