Skip to content

fix: continue draining queue after postMessage errors - #142

Open
SyMind wants to merge 1 commit into
tinylibs:mainfrom
SyMind:codex/continue-queue-after-postmessage-error
Open

SyMind wants to merge 1 commit into
tinylibs:mainfrom
SyMind:codex/continue-queue-after-postmessage-error

Conversation

@SyMind

@SyMind SyMind commented Sep 21, 2026

Copy link
Copy Markdown

Summary

  • report whether WorkerInfo.postTask() successfully posted a task
  • keep draining the pending queue when postMessage() synchronously rejects an unserializable task
  • add a regression test with a blocked worker, an unserializable queued task, and a valid task behind it

Problem

When a worker becomes available, _onWorkerAvailable() removes one task from the queue and returns after calling postTask(). If postMessage() throws, postTask() rejects that task but does not occupy the worker. The scheduler still returns, leaving the worker idle and later queued tasks stuck indefinitely.

This surfaced while removing a redundant structured-clone preflight from Rspack's parallel loader path. A non-cloneable loader input correctly rejected, but the shared pool stopped scheduling later builds.

The fix keeps the task-level rejection and continues the existing scheduling loop only when posting failed. Successful task dispatch remains unchanged and does not add a preflight clone.

Validation

  • vitest run — 99 tests passed
  • tsc --noEmit
  • eslint --max-warnings=0
  • tsdown

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