Skip to content

Runner: fire-and-forget async event posting with server-side ordering - #42

Merged
nissessenap merged 2 commits into
mainfrom
async-fire-and-forget
Mar 1, 2026
Merged

nissessenap merged 2 commits into
mainfrom
async-fire-and-forget

Conversation

@nissessenap

Copy link
Copy Markdown
Owner

Summary

  • Replace synchronous PostEvents in the runner's stdout callback with a fire-and-forget goroutine — prevents blocking the pipe when the API is slow or unreachable
  • Add sort.Slice by sequence in EventHub.Publish so out-of-order delivery from concurrent goroutines is corrected server-side
  • Add backend test (TestEventHub_PublishOutOfOrder_SortsBySequence) and frontend tests for gap detection and exhausted-retry acceptance

Context

See thoughts/plans/2026-03-01-async-event-posting-comparison.md for the full analysis of fire-and-forget vs buffered channel. Fire-and-forget was chosen for its simplicity — the server-side sort in EventHub eliminates the ordering concern that was the main argument for the channel approach.

Supersedes the buffered channel approach from #37.

Test plan

  • TestEventHub_PublishOutOfOrder_SortsBySequence — publishes events as [3, 1, 2], asserts history returns [1, 2, 3]
  • TestRunWithEventPosting — updated with thread-safe mock to verify fire-and-forget goroutines complete
  • Frontend: out-of-order sequence [1, 3, 2] gap detection and stale skip
  • Frontend: exhausted reconnect retries accepts gap and continues
  • All existing EventHub, runner, and frontend tests pass
  • make lint-fix — 0 issues
  • make web-lint-fix, make web-check — clean

🤖 Generated with Claude Code

Replace synchronous PostEvents in the runner's stdout callback with a
fire-and-forget goroutine to prevent blocking the pipe when the API is
slow. Add sort.Slice by sequence in EventHub.Publish so out-of-order
delivery is corrected server-side. Add tests for both the backend
ordering guarantee and frontend gap detection behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nissessenap
nissessenap force-pushed the async-fire-and-forget branch from 824a178 to 867da13 Compare March 1, 2026 21:17
@nissessenap
nissessenap merged commit 3ddd29f into main Mar 1, 2026
4 checks 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.

1 participant