Skip to content

fix(worker): keep fd 0 open when releasing file-backed stdin - #187516

Merged
RomneyDa merged 4 commits into
mainfrom
fix/worker-deploy-stdin-node26
Oct 29, 2026
Merged

RomneyDa merged 4 commits into
mainfrom
fix/worker-deploy-stdin-node26

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Problem

On Node 26, test/scripts/worker-deploy-build-plugin.test.ts aborts with exit status 134:
Assertion failed: (fd > STDERR_FILENO), function uv__close. It reproduces on Linux (node:26.12.1-bookworm) and macOS, on main and on release/2026.10.10. Node 24.22.1 passes.

Root cause: the finally in src/worker/worker-deploy-entry.ts calls process.stdin.destroy(). When stdin is /dev/null (spawned with stdio "ignore") or a regular file, process.stdin is an fs.ReadStream. Node 26 changed lib/internal/fs/streams.js close from if (!stream.fd) to if (stream.fd == null), so destroying it now closes fd 0. Node 24 skipped the close because 0 is falsy. libuv then hands fd 0 to the next worker thread's epoll/kqueue fd, and uv__loop_close asserts when that worker exits.

Fix

A new src/process/release-stdin.ts releaseProcessStdin() decides by the type of fd 0: it leaves a regular file or a non-TTY character device (/dev/null) open, and keeps releasing pipes, sockets, TTYs and an unreadable fd 0 exactly as before. The decision cannot use the stream class: Bun reports even pipe stdin as an fs.ReadStream (probed with Bun 1.4.2), and skipping that destroy would keep the pipe open. The deploy entry calls the helper. runtime-guard.test.ts now asserts the helper call instead of spying on the runner's real stdin, so its result no longer depends on how CI spawned the runner (the first revision failed exactly there under the Bun shard).

Accepted scope: the other process.stdin.destroy() callers either receive pipe stdin or destroy only immediately before exit, so they do not hit this today. Moving them to the helper is a follow-up.

Evidence

  • Before (main, Node 26.12.1 macOS): pnpm test test/scripts/worker-deploy-build-plugin.test.ts → 2 failed / 19 passed, uv__close assertion.
  • After, with runner stdin on /dev/null: worker-deploy-build-plugin 21/21, runtime-guard 100/100, release-stdin 5/5 (pipe, TTY, EBADF released; /dev/null and file kept).
  • Linux Node 26.12.1 (Docker) on the release head with an equivalent guard: 18/18; without it, exit 134. gdb stack: WorkerThread → ~WorkerThreadData → CheckedUvLoopClose → uv__close(backend_fd=0).
  • oxfmt/oxlint clean.

Needed as a backport for 2026.10.10-beta.5 (P1 Linux Node 26 relocated-SQLite abort).

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 29, 2026
@RomneyDa RomneyDa changed the title fix(worker): keep fd 0 open when the deploy entry releases file-backed stdin fix(worker): keep fd 0 open when releasing file-backed stdin Oct 29, 2026
@RomneyDa
RomneyDa merged commit a3dd92b into main Oct 29, 2026
115 checks passed
@RomneyDa
RomneyDa deleted the fix/worker-deploy-stdin-node26 branch October 29, 2026 09:27
RomneyDa added a commit that referenced this pull request Oct 29, 2026
#187553)

* fix(worker): keep fd 0 open when the deploy entry releases file-backed stdin

* fix(worker): decide stdin release by fd type so Bun pipes are still released

* test(worker): assert the stdin release helper instead of the runner's stdin

* test(worker): explain stdin helper mock isolation

(cherry picked from commit a3dd92b)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…w#187516)

* fix(worker): keep fd 0 open when the deploy entry releases file-backed stdin

* fix(worker): decide stdin release by fd type so Bun pipes are still released

* test(worker): assert the stdin release helper instead of the runner's stdin

* test(worker): explain stdin helper mock isolation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant