fix(ext/node): unref stdin on pause to allow process exit#32086
Merged
fraidev merged 1 commit intodenoland:mainfrom Feb 9, 2026
Merged
fix(ext/node): unref stdin on pause to allow process exit#32086fraidev merged 1 commit intodenoland:mainfrom
fraidev merged 1 commit intodenoland:mainfrom
Conversation
2 tasks
bartlomieju
approved these changes
Feb 9, 2026
Member
|
Can you check if this fixes #31871 by any chance? |
Contributor
Author
Unfortunately no, I think is related to unref the worker, maybe this test cover it |
Contributor
|
What about #30747 it feels related (though I tested and it still doesn't work) |
2 tasks
fraidev
added a commit
that referenced
this pull request
Feb 20, 2026
- Fix `child_process` shell command translation to handle shell
redirections (`1>&-`, `< file`), piped commands (`cmd1 | cmd2`), and
shell variable prefixes (`"$NODE"`, `${NODE}`). Previously shell
operators were passed to the CLI arg translator, causing parse failures
or incorrect output.
- Remove duplicate `transformDenoShellCommand` call from
`normalizeSpawnArguments` — it was already called in `buildCommand`, and
the double transformation corrupted POSIX `'\''` quoting.
- Add `wrap_eval` parameter to `op_node_translate_cli_args` so shell
command contexts skip eval code wrapping (which introduces
metacharacters unsafe for shell embedding).
- Map `BrokenPipe` to `EPIPE` (was incorrectly mapped to `EBADF`) in
`stream_wrap`, and catch `BrokenPipe` in `process.stdout`/
`process.stderr` `writeSync` to emit it as an async error event.
- Add minimal `_handle` with `ref()`/`unref()`/`close()` to PIPE stdin.
Intentionally omits `readStart`/`readStop`/`reading` — adding those
resets `_readableState.reading`, which triggers duplicate `_read()`
calls with orphaned reffed promises that prevent process exit.
- Ref `io.stdin` in `_read()` and unref on pause when no `readStop`
exists, matching Node.js event loop ref-counting behavior.
- Add platform-specific quoting in `transformDenoShellCommand`: POSIX
uses single quotes with `'\''` escaping, Windows uses double quotes with
`\\` doubling before `"`.
- Add Windows `cmd.exe` detection (`/d /s /c` pattern) in `buildCommand`
for shell command transformation.
- Deduplicate `--unstable-*` flags in `fork()` between CLI translator
and bootstrap args.
Enables 3 new node_compat tests:
- `test-stdio-closed.js`
- `test-stdout-close-catch.js`
- `test-stdout-close-unref.js`
Needs:
- [x] #32086
- [x] #32087
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.
When process.stdin is a pipe without a _handle (PIPE/TCP type), calling pause() did not unref the underlying Deno stdin resource. This caused pending reads to keep the event loop alive, preventing the process from exiting even after stdin was paused.
This fix adds
io.stdin[UNREF]()in the onpause handler for handleless stdin, andio.stdin[REF]()in _read() to re-ref when reading resumes. This matches Node.js behavior where paused stdin does not keep the process alive.Fixes node_compat test-stdin-child-proc.js timeout.