From fc4624c672a83703112c17d5e8f4e11a25dc920f Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Wed, 28 Jan 2026 21:40:55 -0800 Subject: [PATCH] fix(node:vm): propagate async context tracking flag to NodeVMGlobalObject (#26542) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a `SyntheticModule` callback was wrapped in an `AsyncContextFrame` on the main globalObject (where async context tracking is enabled), evaluating it on a `NodeVMGlobalObject` would crash because the tracking flag wasn't propagated. `AsyncContextFrame::call` checks `isAsyncContextTrackingEnabled()` to decide whether to unwrap the frame — without the flag, it takes the fast path and tries to call the `AsyncContextFrame` wrapper directly, which is not callable. The async context data (`m_asyncContextData`) was already shared between parent and `NodeVMGlobalObject`, but the tracking flag was missing. This adds propagation of `isAsyncContextTrackingEnabled` alongside the data. **Repro:** `react-email` v5.2.5 preview server crashes when rendering a template because it imports `node:async_hooks` (enabling async context tracking) and uses `node:vm` `SyntheticModule` for module evaluation. Fixes #26540 --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/bun.js/bindings/NodeVM.cpp | 2 ++ test/internal/ban-limits.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bun.js/bindings/NodeVM.cpp b/src/bun.js/bindings/NodeVM.cpp index b91a8b829d..d59b9b08ca 100644 --- a/src/bun.js/bindings/NodeVM.cpp +++ b/src/bun.js/bindings/NodeVM.cpp @@ -799,6 +799,8 @@ void NodeVMGlobalObject::finishCreation(JSC::VM& vm) auto* parentGlobalObject = defaultGlobalObject(this); if (parentGlobalObject && parentGlobalObject->m_asyncContextData) { m_asyncContextData.set(vm, this, parentGlobalObject->m_asyncContextData.get()); + if (parentGlobalObject->isAsyncContextTrackingEnabled()) + setAsyncContextTrackingEnabled(true); } } diff --git a/test/internal/ban-limits.json b/test/internal/ban-limits.json index fea8a53a01..4219d0eb41 100644 --- a/test/internal/ban-limits.json +++ b/test/internal/ban-limits.json @@ -44,4 +44,4 @@ "undefined != ": 0, "undefined == ": 0, "usingnamespace": 0 -} +} \ No newline at end of file