Skip to content

Fix test race condition with close event#10

Merged
hawkeyexl merged 2 commits intotest-fixesfrom
copilot/sub-pr-9
Nov 22, 2025
Merged

Fix test race condition with close event#10
hawkeyexl merged 2 commits intotest-fixesfrom
copilot/sub-pr-9

Conversation

Copy link
Contributor

Copilot AI commented Nov 22, 2025

Test failures in CI due to race condition between Node.js child process exit and close events. The exit event fires before stdio streams flush, causing intermittent failures when output isn't fully captured.

Changes

  • Use close event instead of exit: Waits for stdio stream closure before resolving, ensuring all output is captured
  • Add handleCompletion guard: Prevents multiple event handlers from racing to resolve/reject the same promise
  • Fix typo: "sucessfully" → "successfully"
// Before: exit event can fire before streams close
runTests.on("exit", (code) => {
  if (hasExited) return;
  hasExited = true;
  // ... process results
});

// After: close event guarantees streams are closed
runTests.on("close", (code) => {
  handleCompletion(() => {
    // ... process results
  });
});

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI mentioned this pull request Nov 22, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 22, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Co-authored-by: hawkeyexl <5209367+hawkeyexl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix race conditions in test execution Fix test race condition with close event Nov 22, 2025
Copilot AI requested a review from hawkeyexl November 22, 2025 18:05
@hawkeyexl hawkeyexl marked this pull request as ready for review November 22, 2025 18:51
@hawkeyexl hawkeyexl merged commit 210960e into test-fixes Nov 22, 2025
1 check passed
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.

2 participants