Skip to content

fix(runtime): support module-mode process workers - #1842

Merged
Lorenzobattistela merged 4 commits into
bendlang:mainfrom
toprameen:isolate-process-worker-flags
Oct 26, 2026
Merged

Lorenzobattistela merged 4 commits into
bendlang:mainfrom
toprameen:isolate-process-worker-flags

Conversation

@toprameen

@toprameen toprameen commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Running an emitted program through node --input-type=module -e 'await import("./program.cjs")' made Process.run return Fail(5): its helper worker inherited module mode and require was unavailable. The worker now obtains a local require before initialization, preserving inherited permission controls and preloads.

The new JS integration fixture compiles a real Bend program, runs it through Node with both module-flag spellings, and checks its output and a useful worker preload. It fails on the original runtime and passes with the fix.

Node isn't a dependency for the test suite, and instead of adding it, I've made it so the test is skipped if it isn't available in PATH, following precedent elsewhere in the code. Let me know if you would rather I added Node as a dependency instead.

Local checks on macOS with Node 25.8.2 and Bun 1.4.2: source and freshly compiled Bend, emitted Bun/Node, packed test layout, permission deny/allow behavior, and preload auditing. Repository gate: 54/54.

@toprameen
toprameen marked this pull request as ready for review October 24, 2026 01:19
@Lorenzobattistela Lorenzobattistela self-assigned this Oct 26, 2026
process.getBuiltinModule works in both eval module modes, so the worker
no longer waits on an async import before listening, and a rejecting
loader hook cannot leave it silent. The test keeps NODE_OPTIONS out of
the Node runs so its empty-stderr check only sees the fix.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Lorenzobattistela
Lorenzobattistela merged commit a2081c2 into bendlang:main Oct 26, 2026
1 check passed
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.

2 participants