Skip to content

Conversation

@michaelmalave
Copy link
Contributor

Summary

Fixes a race condition in the "403 error after connection" test that caused intermittent failures in GitHub Actions, we see here. The test was using setImmediate to schedule the error event after emitting messages, which could cause the error handler to execute before message handlers completed, resulting in the wrong error message.

Type of Change

  • fix: Bug fix or issue (patch semvar update)

Testing

  • Verified the test passes consistently by running it 50 times locally (previously had ~10% failure rate)
  • All 6 tests in the log-displayer test file pass
  • No regressions introduced

Additional Context

Problem:
The test "when the log server returns a 403 error after connection" was failing intermittently in GitHub Actions (and locally ~10% of the time). The test would expect "Log stream access expired. Please try again." but receive "You can't access this space from your IP address. Contact your team admin."

Root Cause:
After emitting messages synchronously, the test used setImmediate to schedule the error event. In some cases, especially under load or in CI environments, the error handler would execute before the message handlers had completed setting hasReceivedMessages = true, causing the wrong error message to be returned.

Solution:
Replaced setImmediate with process.nextTick when emitting the error after messages. This ensures the current execution phase completes before the error is emitted, guaranteeing that message handlers finish and set hasReceivedMessages = true before the error handler checks it.

Change:

  • Updated packages/cli/test/unit/lib/run/log-displayer.unit.test.ts line 240-242 to use process.nextTick instead of setImmediate for error emission timing

Related Issue

W-20247783

@michaelmalave michaelmalave requested a review from a team as a code owner November 21, 2025 19:36
@git2gus
Copy link

git2gus bot commented Nov 21, 2025

Git2Gus App is installed but the .git2gus/config.json doesn't exist.

@michaelmalave michaelmalave merged commit 8f8b1d6 into main Nov 21, 2025
8 checks passed
@michaelmalave michaelmalave deleted the mm/chore/logdisplayer-test-race-condition branch November 21, 2025 19:41
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