Repository navigation
fix(test/apps): the driver bounds every wait on a child's exit and retries a spawn that fails with EBADF before the child runs (#997) - #1013
Merged
Conversation
…tries a spawn that fails with EBADF before the child runs (#997) AppProcess.stop() now waits at most 5s after SIGKILL. A child that has still not closed is recorded as gone with a note in its log, and its `exited` settles, so serverScript's timeout path and the run's teardown end instead of running to the job timeout. Bun's child_process emits `close` only after the child's pipes close, so a process outside the group that holds them keeps `close` from ever arriving; the new unit test reproduces that with a setsid'd sleep. A spawn that fails with EBADF before the child wrote any output is started once more, with a line in the process log. Any other spawn error, a second EBADF, or an EBADF after output fails as before. Closes #997
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 app scenario driver now gives up on a child that never closes after SIGKILL, and starts a child once more when Bun's spawn fails with
EBADFbefore the child wrote anything.stop()waits at most 5 seconds after SIGKILLBun's
node:child_processemitscloseonly after the child's stdout and stderr close, andAppProcess.exitedsettled only oncloseorerror. A process the group kill does not reach that holds those pipes keepsclosefrom arriving, sostop()awaitedexitedwith no limit and the job ran to its 30-minute timeout (#995's first attempt).stop()now waitstermMsafter SIGTERM andkillMsafter SIGKILL (5 s each by default), then records the process as gone, writes that in its log, and settlesexitedwithnull. Every other wait on a child in the driver was already bounded or goes throughstop():serverScriptracesexitedagainst its timeout and then callsstop(),devServerreadsexitedonly once the process is no longer running, and teardown callsstop()on every process.A SIGTERM that fails because the group is already gone used to return at once with the process still marked running; it now goes through the same bounded wait.
A spawn that fails with
EBADFbefore any output is started once moreOnly
EBADF, only on the first attempt, and only when the child wrote no output. A secondEBADF, any other spawn error, or anEBADFafter output fails the step as before. If the failed child got a pid, its group gets SIGKILL before the new spawn, and events from the abandoned child are ignored.Risk
A real hang in a scenario's process now ends 10 seconds after
stop()begins instead of at the job timeout, with the note above in that process's log. A process recorded as gone may still be alive; the run's temporary directory removal and the runner exiting are what clean up after it, as before.No Bun upgrade here. No Bun issue names this
EBADF ... epoll_ctlspawn failure on Linux (details below).Implementation notes
Runtime path: none beyond the test driver itself. The change is in
test/apps/driver.ts, which every app scenario uses, so the scenario runs below are its integration evidence. The slow scenarios usestop()and pause/resume, so this PR has theci-slow-scenarioslabel.Files:
test/apps/driver.ts,test/apps/driver.test.ts(new),test/apps/README.md,.github/workflows/build.yml(the App scenarios job's unit step runsdriver.test.tsbesideselection.test.ts).AppProcesstakes an optional spawner as its last constructor argument (defaultspawnfromnode:child_process), which the retry tests use for stand-in children without a pid. Thestop()tests use real processes.Local verification, Bun 1.3.11, WSL2:
bun test test/apps/selection.test.ts test/apps/driver.test.ts: 16 pass, 0 failbun test/apps/run.ts --build --skip-slow: 12 apps passed (193.2s)bun test/apps/run.ts --skip-slow: 12 apps passed (140.1s)bun test/apps/run.ts --only-slow: 2 apps passed (143.8s)Bun findings (we pin 1.3.11; latest is 1.4.3):
EBADF ... epoll_ctlfromchild_process.spawnon Linux. Searches: "epoll_ctl EBADF", "bad file descriptor, epoll_ctl", "EBADF spawn", "epoll_ctl".EEXIST: file already exists, epoll_ctlwhile initializing process.stderr fails test files with no named tests oven-sh/bun#37968 (EEXIST ... epoll_ctlcreating stdio streams underbun test --isolate, a stale epoll registration over a reused fd, fixed by test --isolate: end the outgoing file's process stdio sinks at the global swap oven-sh/bun#38008), Native Bun on Linux: intermittent Playwright chromium.launch() failure — connect ENOENT in child_process #createStdioObject on browser recycle under sustained load oven-sh/bun#34785 (intermittentconnect ENOENTinchild_processstdio setup under load, fixed in 1.4.0).EPOLLONESHOT); 1.4.2 fixed aFileSinkfd closed twice when its epoll registration failed, which could close an unrelated descriptor that reused the number; 1.4.3 fixedBun.spawnreusing fd 0 to 2 for its pipes after user code closed them, and spawn blocking onEMFILE. Any of these could be related; none names this error.bun test --parallel).