fix: prevent message loss when new message arrives as idle timeout fires#802
Open
dptts wants to merge 3 commits intoqwibitai:mainfrom
Open
fix: prevent message loss when new message arrives as idle timeout fires#802dptts wants to merge 3 commits intoqwibitai:mainfrom
dptts wants to merge 3 commits intoqwibitai:mainfrom
Conversation
Demonstrates the message-loss race fixed in the parent commit: after closeStdin() fires (idle timer), sendMessage() must return false even while state.active is still true. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Mar 8, 2026
apatella
reviewed
Mar 8, 2026
apatella
left a comment
There was a problem hiding this comment.
The fix logic looks reasonable — the race between an incoming message and the idle timeout firing is a real edge case worth handling.
Two files need Prettier formatting before CI will pass:
src/group-queue.tssrc/group-queue.test.ts
Quick fix:
npx prettier --write src/group-queue.ts src/group-queue.test.tsOnce formatted, CI should be green. Nice catch on this bug! 👍
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.
Type of Change
.claude/skills/Description
I added added support for agents to respond to webhooks and found a race condition. GroupQueue.sendMessage() could silently drop incoming messages.
Sequence:
Fix
Add a closing: boolean flag to GroupState. closeStdin() sets it; notifyContainerStart() clears it (reset for the next run). The sendMessage() guard gains || state.closing, making it return false during the window between idle-timeout and container exit. The caller then treats this as a queued pending message, which is processed in the next container run.
Evidence
The regression test in this PR (src/group-queue.test.ts) was written to fail on unfixed code and pass on the fix.
For Skills