Repository navigation
Conversation
Owner
Author
|
Thanks go to @volker-fr for the report and helping with solving the issue. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Slack conversation streaming pipeline and the chunk control runner against shutdown deadlocks by making producer/worker sends cancellation-aware, ensuring all internal goroutines are joined/drained before returning, and adding regression coverage around cancellation and generator coordination.
Changes:
- Refactors the conversations pipeline to cancel on first fatal error/callback failure while still draining results and joining all producers/workers before returning.
- Makes result, channel-request, and thread-request sends cancellation-aware; adjusts thread channel close ownership to avoid close/send races.
- Coordinates
runWorkerswith a cancelable generator context and concurrent generator-error draining; deduplicates channel user IDs during streaming; adds targeted regression tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| stream/stream.go | Moves pipeline buffer-size constants out of the main stream file. |
| stream/stream_workers.go | Makes result sends cancellation-aware via sendResult to prevent worker/producers blocking after early consumer return. |
| stream/stream_test.go | Updates processLink tests for new context-aware signature and adds a cancellation unblock regression case. |
| stream/conversation.go | Refactors pipeline orchestration to cancel/drain/join deterministically; adds cancellation-aware request routing and channel-user dedupe helper. |
| stream/conversation_test.go | Adds regression tests covering fatal cancellation, callback failure shutdown, external cancellation, nonfatal handling, blocked send unblocking, and user dedupe. |
| internal/chunk/control/runner.go | Updates conversation worker to cancel/join the API generator deterministically and drain generator errors concurrently. |
| internal/chunk/control/runner_test.go | Adds regression test ensuring generator is canceled/unblocked when conversations fail. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Problem
When conversation processing returned on the first fatal result or callback error, its producers and workers could remain blocked:
runWorkerswaited for it;A SIGQUIT stack trace from a production hang showed this exact pattern:
runWorkerswaiting for the generator, the generator blocked emitting channels, and conversation workers blocked on result sends after the consumer had returned.In addition, after the fix, the original error that led to Hang-up was discovered —
to address it a channel users slices deduplication was introduced during streaming.
Solution
Conversationsan internal cancellable context and retain the first fatal result or callback error.threadsConly after both the input loop and channel worker have stopped.channel_not_foundandnot_in_channelhandling.runWorkerswith a shared generator/conversation context and concurrently drain generator errors, removing the fixed error-channel capacity.ConversationsCBitem producer deterministically.Validation
go test -race ./stream ./internal/chunk/controlgo test ./... -run '^$'git diff --check