Skip to content

test(core): remove readiness race in AppProcess interruption tests - #51952

Closed
saulalfonsos wants to merge 3 commits into
anomalyco:devfrom
saulalfonsos:process-test-race
Closed

saulalfonsos wants to merge 3 commits into
anomalyco:devfrom
saulalfonsos:process-test-race

Conversation

@saulalfonsos

Copy link
Copy Markdown

Issue for this PR

Closes #51951

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Test-only fix. The child process in the two AppProcess interruption tests announced it was ready before installing its SIGTERM handler, and wrote the ready file with writeFileSync, which leaves an empty file for a moment. Under load the test read it empty or signalled too early.

The child now registers the handler first and writes both marker files atomically (temp file + rename), via a small shared helper used by both tests. No production code changes.

How did you verify your code works?

Ran bun test test/process/process.test.ts 16 times in parallel for 60 rounds (960 runs): 0 failures with the fix. Before, the readiness failure showed up under the same load. bun typecheck in packages/core passes.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The child process in the two interruption tests wrote its `ready` file
before installing its SIGTERM handler, and wrote it with writeFileSync,
which creates the file empty before filling it. On a loaded machine the
test could read `ready` as empty (`Received: ""`) or send SIGTERM before
the handler existed, so the child died without writing `settled`.

The child now installs the handler first and publishes both files
atomically (write to a temp file, then rename), in a shared helper.
Measured with 16 runs of the file in parallel: 0 failures in 960 runs.
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(core): flaky AppProcess interruption tests (readiness race)

2 participants