Add heartbeats to StreamBuildEvents wait-for-log-file loop#176
Open
hiroTamada wants to merge 1 commit intomainfrom
Open
Add heartbeats to StreamBuildEvents wait-for-log-file loop#176hiroTamada wants to merge 1 commit intomainfrom
hiroTamada wants to merge 1 commit intomainfrom
Conversation
When a build is queued, StreamBuildEvents waits for the log file to appear before streaming logs. During this wait, no events are sent on the SSE connection. Infrastructure proxies (e.g. Railway) terminate idle SSE connections after ~60 seconds, causing the Kernel API to see a "build timed out" error even though the build hasn't started yet. Add a 15-second heartbeat ticker to keep the SSE connection alive while waiting for the log file. The existing 30-second heartbeat in the main streaming loop already handles the active-build case. Made-with: Cursor
Sayan-
approved these changes
Mar 30, 2026
Comment on lines
+1150
to
+1154
| select { | ||
| case out <- BuildEvent{Type: EventTypeHeartbeat, Timestamp: time.Now()}: | ||
| case <-ctx.Done(): | ||
| return | ||
| } |
There was a problem hiding this comment.
inner select seems redundant relative to the outer but nbd
| } | ||
| break | ||
| } | ||
| waitHeartbeat.Stop() |
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.
Summary
StreamBuildEventswait-for-log-file loopContext
During a bulk migration of Unikraft deployments to Hypeman, builds queued behind others consistently timed out after exactly 60 seconds. Root cause: the SSE stream was idle during the queue wait, triggering an infrastructure idle timeout.
Test plan
max_concurrent_source_builds) to force queuingMade with Cursor
Note
Low Risk
Low risk, localized change to
StreamBuildEventsthat only adds periodic heartbeat events during the pre-log wait; main behavioral risk is extra event traffic or unexpected client handling ofheartbeatevents.Overview
Prevents idle timeouts for queued builds by emitting
heartbeatevents whileStreamBuildEventsis waiting for the build log file to appear.This adds a 15s ticker in the wait-for-log-file loop (before
tailstarts) so SSE clients keep receiving events until logs begin streaming or the build reaches a terminal status.Written by Cursor Bugbot for commit bffcd3e. This will update automatically on new commits. Configure here.