Skip to content

fix: gok logs: fix races happening in CI - #103

Merged
stapelberg merged 2 commits into
gokrazy:mainfrom
damdo:fix-test-logs
Jun 23, 2026
Merged

fix: gok logs: fix races happening in CI#103
stapelberg merged 2 commits into
gokrazy:mainfrom
damdo:fix-test-logs

Conversation

@damdo

@damdo damdo commented May 27, 2026

Copy link
Copy Markdown
Contributor

This PR fixes a couple of flakes I've encountered during CI runs on this repo:

  • gok logs: don't call stream.Close() to avoid send-on-closed-channel panic
    2101e43
    The eventsource library's background goroutine may still be sending on
    the Events/Errors channels when Close() is called, causing a panic.
    Context cancellation already aborts the HTTP request, which makes the
    library goroutine exit on its own.

  • gok logs: fix data race on http.Client.CheckRedirect
    6d2603f
    eventsource.SubscribeWith mutates the passed http.Client's
    CheckRedirect field. Since streamLog is called concurrently for
    stdout and stderr, this is a data race. Clone the client before
    passing it to the library.
    Add TestStreamLogConcurrentCancel to exercise both the concurrent
    client usage and context cancellation under the race detector.

damdo added 2 commits May 27, 2026 12:44
…anic

The eventsource library's background goroutine may still be sending on
the Events/Errors channels when Close() is called, causing a panic.
Context cancellation already aborts the HTTP request, which makes the
library goroutine exit on its own.

This fixes TestGokRun failing in CI with:
  panic: send on closed channel
eventsource.SubscribeWith mutates the passed http.Client's
CheckRedirect field. Since streamLog is called concurrently for
stdout and stderr, this is a data race. Clone the client before
passing it to the library.

Add TestStreamLogConcurrentCancel to exercise both the concurrent
client usage and context cancellation under the race detector.
@damdo
damdo marked this pull request as ready for review May 28, 2026 17:49
@stapelberg
stapelberg merged commit ef964f3 into gokrazy:main Jun 23, 2026
3 checks passed
@stapelberg

Copy link
Copy Markdown
Contributor

Thanks!

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