Repository navigation
fix: load Worker entries served over HTTP - #29
Merged
Merged
Conversation
new Worker() resolved every specifier as a file and read it from disk, so a
dev server URL (new URL('./x.worker.ts', import.meta.url) under HMR) failed
with os error 123. HTTP entries now skip the disk read and the worker's thread
imports them through the native module loader, so the entry's own imports
resolve against the URL. A failed load is reported as a worker error.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
new Worker()treated every specifier as a file path and read it from disk. Under the Vite dev server,new Worker(new URL('./x.worker.ts', import.meta.url))passes anhttp://127.0.0.1:5174/ns/m/...URL, which turned into an invalid Windows path:Reported in triniwiz/nativescript-canvas-starter-template#1.
Changes
worker_support.rs: anhttp(s)://specifier skips the resolve and disk read and goes to the threaded host as the worker's filename. Without the threaded host, this now throws a clear error instead of running an empty script.worker_threads.rs: the worker bootstrapimport()s an HTTP filename through the native module loader, so the entry's own imports resolve against its URL. The dev server already serves worker realms with HTTP vendor imports, so the worker doesn't need an import map. A failed load is queued back as a worker error (delivered asmessageerror).esm_http_test.rs:worker_entry_served_over_httpcovers a served worker entry with a relative import, and a missing entry surfacing its 404.