Repository navigation
fix(approvals): save and wait on a request before the chat shows it - #186
Merged
Merged
Conversation
approvals::open announced the approval's chat item before saving the approval, and the answer's channel was registered after that. A fast app could answer a request that was not in the store yet (not found, seen on CI's Linux runner in a browser test), or answer before the daemon waited on it, so the bot would only hear back when the request expired. Now the chat item and the approval are saved, the answer is waited on, and only then does the app hear of it.
httpsphl
enabled auto-merge
October 5, 2026 00:56
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.
Found while looking at a red CI on httpsphl/botloft#184.
words_made_of_one_element_per_letter_keep_their_spacesfailed on Ubuntu withapprovals.answer→-32002 approval … not found. The rerun passed.Cause
approvals::opencalleditems::add, which saves the chat item and emitschat.item, beforeinsert_approval. The answer's oneshot was also registered indaemon.approvalsonly afteropenreturned. That leaves two windows:not found.Fix
opennow does these steps in this order:items::announce.Spec 10.1 records the order.
Test
tests/approval_order.rsanswers 20 suggestions synchronously the moment theirchat.itemevent arrives. Each answer must find the request, and the bot must hear it within 5 s. Locally, this test does not reproduce the race on the old code, because the emit and the insert run back to back on one thread. It guards the order, as CI's Linux runner showed it can break.