Repository navigation
test(async_hooks): cover module-loader async context propagation - #111
Merged
Merged
Conversation
Requires OpenClaw WebKit. Cover static and dynamic graphs, top-level await, CommonJS, shared and overlapping imports, cached modules, rejection and unscoped calls. The same fixture supports Node registerHooks controls. Related to oven-sh#37933 and oven-sh/WebKit#274. Co-authored-by: robobun <117481402+robobun@users.noreply.github.com>
This was referenced Oct 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cover module-loader AsyncLocalStorage propagation with isolated subprocesses for static and dynamic dependencies, nested imports, top-level await, CJS, concurrent distinct/shared/overlapping graphs, cached modules, unscoped imports and errors. Each case runs with Bun plugins and Node-compatible synchronous module hooks; the fixture also supports a Node control.
The matching engine captures context per loader promise reaction. Shared modules keep the first importer's evaluation context, while each caller resumes in its own store. This catches the earlier resolver/loader boundary rather than only checking evaluation. The fixture normalizes native Windows paths and file URLs before comparing hook events.
Requires OpenClaw WebKit, pinned on main by #108. Related upstream work: oven-sh#37933 and oven-sh/WebKit#274; thanks @robobun. No duplicate upstream PR is opened for engine-dependent coverage.
Before: 24 scoped cases fail and four controls pass on old-engine Bun. All 14 Node 24 variants pass. OpenClaw capture-lifetime is 2/3 on old-engine Bun versus 3/3 on Linux Node. After: all 28 loader cases pass; the surrounding async-hooks, module-hook and plugin suites pass 541 tests with one todo and zero failures across eight files. The OpenClaw capture-lifetime consumer passes 3/3, matching Node. The expanded plain fork selection remains 47/47 with zero regressions. The final branch passes scoped Codex P2 review with the recorded Node oracle evidence. Both exact-head CI lanes pass: Linux x64 and macOS arm64.
Native proof was built at
32de1cc419b7e954246b6f87cada5bc06fdda34a; final heade29d475aea27ebca983f5da26c4c158710bfe0c5differs only by the inherited Rust safety comment from #110 and one comment explaining the observed Node overlap semantics. A strict source comparison confirms the runtime logic and test inputs are unchanged. All four consumers also pass on the fully integrated stack.In the overlapping top-level-await case, the Node 24 control records the second module body in context A, its loader hooks and caller in B, and the independent ready module body in B. The fixture deliberately preserves that distinction; the explanatory comment does not alter any assertion.