Conversation
When stdout is a pipe whose reader exits early (e.g. `s ... | head`), writes after that fail with EPIPE. The uncaughtException handler passes the error to handleError, which writes to stdout again and spawns a report.js telemetry daemon per cycle, forming a self-sustaining loop: the process never exits and node child processes pile up. - register EPIPE guards on process.stdout/stderr (Unix SIGPIPE semantics) - short-circuit EPIPE in the uncaughtException handler - add a regression test that pipes `s` output to an early-exiting reader Signed-off-by: 肖佳权 <1259103745@qq.com>
weisanju
force-pushed
the
fix/epipe-infinite-loop
branch
from
September 16, 2026 01:10
8d0810d to
8893866
Compare
This branch has not been deployed
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.
Fix bugs
Bug detail
When a command error occurs while stdout is connected to a pipe whose reader exits early (e.g.
s info -t s.yaml 2>&1 | head -5), the CLI enters a never-ending error-handling loop and piles up node processes:${env('X')}referencing an unset environment variable in s.yaml) is reported byhandleError, which writes the error message to stdout and spawns areport.jstelemetry daemon (src/exec-daemon.ts).head) has exited, every further write to stdout fails withEPIPE, which surfaces as anuncaughtException.uncaughtException→handleError→ writes to stdout again + spawns another daemon →EPIPE→ …Each cycle spawns one detached node child (
lib/daemon/report.js, alive ~30s), so the process table fills up until the system pid limit. The CLI process itself never exits on its own; repeated EPIPE records also grow the log file without bound (~16 cycles/s on Linux, much faster on macOS).Reproduced in a resource-limited container (node:22,
--pids-limit, no network) withtimeout 15sas watchdog:@serverless-devs/s@3.1.10(npm), error +| head -5| head -5~/.s/logsFix (standard Unix SIGPIPE semantics — when the pipe reader is gone, exit instead of writing again):
errorlisteners onprocess.stdout/process.stderrthat exit onEPIPE(src/index.ts);EPIPEin theuncaughtExceptionhandler instead of re-entering the error-handling flow.Pull request tasks
Regression test in
__tests__/error.test.ts: pipes the CLI output to an early-exiting reader. Before the fix thespawnSynccall is killed by its timeout (the pipeline never exits,ETIMEDOUT); with the fix it finishes in ~200 ms.