Skip to content

fix(core): isolate loader configuration between worker threads - #888

Merged
Brooooooklyn merged 3 commits into
fengmk2/fix-ci-artifact-downloadsfrom
fengmk2/fix-worker-loader-context
Oct 24, 2026
Merged

Brooooooklyn merged 3 commits into
fengmk2/fix-ci-artifact-downloadsfrom
fengmk2/fix-worker-loader-context

Conversation

@fengmk2

@fengmk2 fengmk2 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

After the parent transforms a file, a worker cannot select a different tsconfig. The native addon shares configuration and resolver caches across threads.

Give each JavaScript thread its own loader context. Native asynchronous transforms use their caller's context, including configuration selected from that thread's process.env. An asynchronous transform selects its configuration when the caller submits it.

module.register() receives the selected configuration and dependency mode. Registration freezes both settings, so later changes cannot make CommonJS and ESM use different settings.

Rust embedders use OxcTransformer::capture_context() before queuing work and CapturedLoaderContext::with() inside the task. Each scoped call restores the task thread's prior context after completion or panic.

Fixes #884.

@fengmk2
fengmk2 added this pull request to stack #889 October 23, 2026 08:46
@fengmk2 fengmk2 changed the title fengmk2/fix worker loader context fix(core): isolate loader configuration between worker threads Oct 23, 2026
@fengmk2
fengmk2 requested a review from Brooooooklyn October 23, 2026 08:48
@Brooooooklyn
Brooooooklyn merged commit 7e0b895 into main Oct 24, 2026
67 checks passed
@Brooooooklyn
Brooooooklyn deleted the fengmk2/fix-worker-loader-context branch October 24, 2026 03:11
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.

Worker threads cannot select an independent tsconfig after the parent transforms a file

2 participants