Repository navigation
fix(server): child exiting with unread fd input no longer crashes the server - #58
Merged
Merged
Conversation
… server On Linux, Node opens extra stdio fds as duplex sockets that it also reads. Effect's spawner only listens for errors on an input fd while a write is in flight, so when headless Chrome exited with unread CDP input on fd 3 the socket reset (read ECONNRESET) was an unhandled 'error' event and killed the whole server. Patch @effect/platform-node-shared to keep a listener on input fds for their whole life; write failures still reach the sink.
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.
The lax6e remote server crashed 9 times since Oct 8, dropping every connected client each time. Every crash had the same trace:
Error: read ECONNRESET at Pipe.onStreamReademitted as an unhandled'error'event on a Socket, then systemd restarted the service.Cause: headless Chrome (used for HTML previews) talks CDP over
--remote-debugging-pipe, which uses extra stdio fds 3 and 4. Node opens extra fds as duplex sockets and reads from them, even ones we only write to. On Linux, when a child exits with unread data in its fd 3 receive buffer, our end of the socket gets reset.@effect/platform-node-shared's spawner only listens for errors on an input fd while a write is in flight, so an idle fd 3 has no listener and the reset kills the process. macOS doesn't reset the socket here, which is why only the Linux remote crashed.Fix: patch
@effect/platform-node-shared@4.0.2to keep an error listener on input fds for their whole life. Write failures still reach the sink's own listener, and the child's exit is still reported throughexitCode. Patching the spawner fixes every caller, includingDesktopBackendManager's input fds, not only Chrome.Verification:
read ECONNRESET, patched passes 3/3.vp test run src/process/childProcessFds.test.tspasses locally (macOS can't reproduce the crash, so CI on ubuntu is the run that guards it).apps/servertypecheck is clean.Not covered: child
stdinhas the same "listener only while writing" shape, but Node doesn't read from it, so it can't produce this read reset. I left it alone.🤖 Generated with Claude Code