Skip to content

test(async_hooks): cover module-loader async context propagation - #111

Merged
steipete merged 2 commits into
mainfrom
claude/w141-als-module-context
Oct 4, 2026
Merged

steipete merged 2 commits into
mainfrom
claude/w141-als-module-context

Conversation

@steipete

@steipete steipete commented Oct 4, 2026 •

Copy link
Copy Markdown

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 head e29d475aea27ebca983f5da26c4c158710bfe0c5 differs 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.

steipete and others added 2 commits October 4, 2026 14:49
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>
@steipete
steipete merged commit e0a6045 into main Oct 4, 2026
7 of 8 checks passed
@steipete
steipete deleted the claude/w141-als-module-context branch October 4, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant