Skip to content

fix(llmlingua): pass a URL object to new Worker() instead of a file:// string - #12823

Closed
anhtahaylove wants to merge 1 commit into
diegosouzapw:release/v3.8.51from
huuhungn:fix/llmlingua-worker-path
Closed

anhtahaylove wants to merge 1 commit into
diegosouzapw:release/v3.8.51from
huuhungn:fix/llmlingua-worker-path

Conversation

@anhtahaylove

Copy link
Copy Markdown
Contributor

Fixes #12822.

Problem

new Worker() does not accept a serialized file:// string — it wants an absolute path, a ./-relative path, or a WHATWG URL object. worker.ts:237 passed pathToFileURL(...).href, so every spawn threw ERR_WORKER_PATH:

TypeError [ERR_WORKER_PATH]: The worker script or module filename must be an
absolute path or a relative path starting with './' or '../'.
Wrap file:// URLs with `new URL`. Received "file:///.../onnxWorker.js"

pump() catches spawn failures and fail-opens, so the LLMLingua engine silently returned uncompressed text instead of surfacing an error. The engine has effectively been a no-op wherever the dependency gate passes.

Fix

-const w = new Worker(pathToFileURL(absoluteWorkerFile).href, { execArgv });
+const w = new Worker(pathToFileURL(absoluteWorkerFile), { execArgv });

This matches compressionWorkerPool.ts, which already passes the URL object returned by pathToFileURL() and spawns correctly. The two call sites now agree.

Verification

Against the real onnxWorker.js from an installed 3.8.50, Node v24.19.0:

call result
new Worker(pathToFileURL(f).href, …) (current) ERR_WORKER_PATH
new Worker(pathToFileURL(f), …) (this PR) spawns, terminates cleanly

Also exercised end-to-end through workerBackend() with the optional deps shimmed: before the change an 80-char input came back 80 chars unchanged (fail-open); after it, the worker starts and the round-trip reaches the worker.

Note on error visibility

This PR is the minimal correctness fix. Separately, the bare catch {} around ensureWorker() is what let a 100% spawn failure go unnoticed — worth at least a debug-level log so a broken worker path cannot masquerade as "compression ran, saved nothing". Happy to add that here or in a follow-up, whichever you prefer.

Relation to my other PRs

Independent of #12813 / #12815 / #12820 — different file, no overlap, any merge order works.

…/ string

new Worker() rejects a serialized file:// string with ERR_WORKER_PATH, so the
LLMLingua ONNX worker never spawned. pump() swallows the spawn error and
fail-opens, so every call silently returned uncompressed text.

Pass the WHATWG URL object from pathToFileURL() directly, matching how
compressionWorkerPool.ts already spawns its worker.
@anhtahaylove

Copy link
Copy Markdown
Contributor Author

Superseded by #13093, which carries the identical source change plus a regression test and a changelog entry. Closing this one to keep the review queue unambiguous — no need to review both.

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.

fix(backend): LLMLingua worker never spawns: new Worker() gets a file:// string, throws ERR_WORKER_PATH, silently fail-opens

1 participant