fix(runtime): capture blob worker roots before revocation#35128
fix(runtime): capture blob worker roots before revocation#35128divybot wants to merge 5 commits into
Conversation
Co-Authored-By: Divy Srivastava <me@littledivy.com>
|
Confirmed the JS race fix works (the added spec test passes), but this introduces a TypeScript regression: TS blob module workers no longer transpile. Repro (works on const code = `
const x: number = 42;
self.onmessage = (e: MessageEvent) => { self.postMessage(x); };
`;
const url = URL.createObjectURL(new Blob([code], { type: "application/typescript" }));
const w = new Worker(url, { type: "module" });
URL.revokeObjectURL(url);
w.onmessage = (e) => { console.log("got", e.data); w.terminate(); };
w.postMessage(0);On Root cause: Note the blob is captured for every module blob worker, not only revoked ones, so this breaks all TS blob module workers — even without Suggested direction: for the captured-content root, route through the inner loader's transpilation rather than returning raw bytes (the content is already injected into the graph via (Minor, separate: the PR description lists |
Move the blob/object-URL worker root capture from a runtime module-loader wrapper into the CLI module loaders. The previous wrapper served the captured blob's raw bytes for the root, which dropped the blob's media type and broke transpilation of TypeScript blob module workers. The capture is still taken synchronously at worker construction (so a racing URL.revokeObjectURL can't break the load), but now the captured content AND its content-type are injected into the worker's module graph (deno run) / preferred over the revoked object-URL lookup (compile), so the normal load path handles charset decoding and TS/JSX transpilation. Adds a TypeScript case to the worker_blob_url_revoke spec.
|
Thanks @bartlomieju — good catch. You were right that the root cause was serving the captured blob's raw bytes for the root, which dropped the media type so Fixed by moving the capture out of the runtime module-loader wrapper and into the CLI module loaders, where the media type can be preserved:
The runtime-side Tests: added a TypeScript case to Re: the compile spec command in the description — that refers to the pre-existing |
|
Heads up on the one red check ( |
…ming Merging main brings in #34397, which emits a legacy-abort deprecation warning when a Deno.serve handler uses legacy request.signal abort on a successful response. The request_signal_streaming spec exercises exactly that path, so its expected output must include the warning line. Same fix as the closed #35191 (folded into #35133); included here so this PR's CI is self-sufficient. Unrelated to the blob-worker change.
The 'test specs (2/2) release linux-x86_64' job failed in the 'Set up incremental LTO and sysroot build' step because apt could not reach apt.llvm.org (Network is unreachable / connection timed out) while installing LLVM packages — before any test ran. No source change; lacking admin rerun rights, an empty commit re-triggers CI on a fresh runner.
Captures blob/object URL worker root modules during
new Worker(blobUrl)so immediateURL.revokeObjectURL(blobUrl)does not race with worker graph preparation or module loading. The captured blob is used only for the worker root; dependencies and loader hooks still delegate to the normal module loader.Adds a
deno runregression spec for repeatedly constructing module workers from blob URLs and revoking each URL synchronously.Tests:
cargo fmt --checkcargo check -p deno_runtimecargo build -p deno --bin denocargo build -p test_servercargo test --test specs specs::worker::worker_blob_url_revokecargo build -p denort --bin denortcargo test --test specs specs::compile::worker_blob_url_revokeCloses #26142
Closes denoland/divybot#541