Skip to content

fix(compression): drain the worker pool queue when worker construction throws - #12755

Open
insoln wants to merge 14 commits into
diegosouzapw:release/v3.8.51from
insoln:fix/compression-worker-pool-queue-jam
Open

fix(compression): drain the worker pool queue when worker construction throws#12755
insoln wants to merge 14 commits into
diegosouzapw:release/v3.8.51from
insoln:fix/compression-worker-pool-queue-jam

Conversation

@insoln

@insoln insoln commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Prevents the compression worker pool from retaining queued request bodies when worker construction throws synchronously.

This is deliberately a containment fix: it removes the queue-retention failure mode and makes fail-open behavior observable, but it does not repair the standalone build's worker resolution or worker dependency packaging. Compression still returns the original body when no worker can be created.

Changes

  • Drain every queued job fail-open when worker construction throws.
  • Permanently short-circuit only known structural spawn failures; retry transient and unknown failures on the next request wave.
  • Settle in-flight work on worker errors, exits, timeouts, postMessage throws, and pool shutdown.
  • Add rate-limited, sanitized fail-open warnings.
  • Pass a URL object to the LLMLingua worker constructor on Node.js 21+.
  • Register the regression suite in Stryker's tap.testFiles.

Validation

  • node --import tsx/esm --test tests/unit/compression/compression-worker-pool-jam.test.ts — 14 passed
  • Adjacent compression and LLMLingua regression suites — 68 passed
  • PR-mode complexity ratchets — unchanged (complexity 9 → 9; cognitive-complexity 3 → 3)
  • Focused Prettier and git diff --check — passed
  • Three specialized review passes found no remaining actionable defects.

The release branch is currently red independently of this change. The inherited failures include the glm.ts TS2554 error, invalid changelog fragment, provider-asset provenance object, mutation-list drift for quotaScoring.ts, and unrelated unit-test failures.

⚠️ base-red inherited: #12732

Tests Added

  • tests/unit/compression/compression-worker-pool-jam.test.ts

Out of scope

  • Repairing the Turbopack worker module-context rewrite.
  • Repairing the dependency closure of the separately bundled compression worker.

…ronously

A synchronous spawn failure (Turbopack standalone moduleContext
MODULE_NOT_FOUND) escaped dispatch() before queue.shift(), stranding
every queued job — each holding a full parsed request body — in
pool.queue for the process lifetime (unbounded main-isolate heap leak,
#2).

- dispatch() now fail-opens the whole queue on a spawn throw and marks
  the pool broken: subsequent run() calls resolve unchanged immediately
  instead of re-jamming
- constructor accepts a workerFactory test seam
- strategySelector fail-open catch now logs (rate-limited): the leak was
  invisible precisely because the catch was silent
- llmlingua worker passes a URL object to new Worker (ERR_WORKER_PATH on
  Node >= 21 for file:// strings)
…and dark llmlingua catches

- extract notifyCompressionFailOpen into failOpenNotifier.ts (import-cycle-free)
- broken-pool run() now notifies instead of failing open silently forever
- rate limiter keys on detail so distinct new failure modes are never swallowed
- llmlingua pump/postMessage catches log through the notifier
@insoln
insoln marked this pull request as ready for review September 4, 2026 23:28
@insoln
insoln requested a review from diegosouzapw as a code owner September 4, 2026 23:28
- errorText/strategySelector/llmlingua now pass the raw unknown to
  sanitizeErrorMessage (never String(error), which throws on hostile
  toString/valueOf) so run() cannot reject on a non-Error spawn failure
- add an injectable worker harness to the llmlingua backend and cover the
  spawn-throw and postMessage-throw fail-open paths (original text, queue
  continuation, respawn, rate-limited warn)
- add hostile-throwable regression test for the pool
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.

1 participant