Repository navigation
node child process maxbuf support - #18293
Merged
Merged
Conversation
Collaborator
|
Updated 5:02 PM PT - Apr 3rd, 2025
✅ @pfgithub, your commit 605e0887cf643a214179b87616e912b52a703276 passed in 🧪 try this PR locally: bunx bun-pr 18293 |
pfgithub
force-pushed
the
pfg/child-process-4
branch
from
March 21, 2025 00:17
f54bda6 to
8afd7a5
Compare
pfgithub
force-pushed
the
pfg/child-process-4
branch
from
March 27, 2025 03:13
06ed332 to
06380e2
Compare
Collaborator
|
suspicious flaky test |
pfgithub
marked this pull request as ready for review
March 31, 2025 21:23
pfgithub
commented
Apr 3, 2025
pfgithub
commented
Apr 3, 2025
pfgithub
commented
Apr 3, 2025
Jarred-Sumner
pushed a commit
that referenced
this pull request
Aug 2, 2026
…wnSync timeout (#36792) Follow-up to #36782, which unquarantined `spawn-maxbuf.test.ts` and exposed a latent boundary flake in a different subtest. ## Failure ``` 240 | expect(timeEnd - timeStart).toBeGreaterThan(100); // make sure it actually waits error: expect(received).toBeGreaterThan(expected) Expected: > 100 Received: 100 ✗ timeout kills the process > Bun.spawnSync [101.64ms] ``` Seen on main [build 87859](https://buildkite.com/bun/bun/builds/87859) (alpine 3.23 x64, retry passed) and [build 87890](https://buildkite.com/bun/bun/builds/87890) (debian 13 aarch64, red on every retry). The assertion has been in the file since #18293; it was hidden by the whole-file `[ FLAKY ]` quarantine until #36782 removed it. ## Cause The `spawnSync` timeout deadline is computed as `CLOCK_MONOTONIC + 100ms` at nanosecond precision (`js_bun_spawn_bindings.rs`: `now.add_ms(timeout_ms)`), and the timeout fires when `CLOCK_MONOTONIC >= deadline` (`SpawnSyncEventLoop::tick_with_timeout`). So by the time `spawnSync` returns, at least 100ms of monotonic time has elapsed. The test measures with `Date.now()`, which truncates the wall clock to whole milliseconds. For a real elapsed interval of 100.x ms, `floor(end) - floor(start)` can be exactly 100 (e.g. start at T+0.1ms → `Date.now()=T`, end at T+100.2ms → `Date.now()=T+100`). The test duration `[101.64ms]` in the CI output confirms the wait itself was not short. Local 500-iteration probe on release: ``` {"min":100,"hit100":7,"under100":0,"iterations":500} ``` The delta lands on exactly 100 in ~1.4% of runs and never goes below 100, so `>=` is the tight bound. ## Fix Change `toBeGreaterThan(100)` to `toBeGreaterThanOrEqual(100)`. The lower bound is kept because it is the only thing in this test that would catch `timeout: 100` being misread as `timeout: 0` (the `exitedDueToTimeout`/`signalCode` checks would still pass if the kill fired immediately). Node's own `test-child-process-spawnsync-timeout.js` only asserts the upper bound and relies on `error.code === 'ETIMEDOUT'`; Bun's `exitedDueToTimeout` is equivalent, but the `>= 100` here is cheap extra coverage. The sibling `toBeGreaterThan(1000)` assertions in the `timeout Infinity` block measure a child `sleep 1` plus `bunExe()` startup, which is always comfortably above 1000ms, so they are left as-is. ## Verification ``` $ bun bd test test/js/bun/spawn/spawn-maxbuf.test.ts 16 pass 0 fail ``` Five consecutive full-file debug runs pass. Test-only change; no runtime behaviour is touched. <!-- robobun:evidence:begin --> --- **no test proof** · iteration 0 · Platform-specific test-only change; deferring to CI. <!-- robobun:evidence:end -->
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.
What does this PR do?
sync only
part of BUN-10684, Fixes BUN-12626, Fixes BUN-13251
TODO:
100won't store546173bytes of output before the process is killed)test failures:
not tested:
sometimes channel won't be 'null' on close on linux musl
this is because sometimes 'process.on("close")' comes before 'process.on("disconnect")'
this is probably supposed to always be called before close?
it reproduces easily in rr