fix(daemon): crash when fully synced and no new events arrive#375
Merged
andreabadesso merged 2 commits intorelease-candidatefrom Mar 5, 2026
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
raul-oliveira
approved these changes
Mar 4, 2026
pedroferreira1
approved these changes
Mar 4, 2026
This was referenced Mar 5, 2026
Merged
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.
Motivation
The daemon crashes on startup when the fullnode has no new events to send (i.e. the daemon is fully synced).
Here is the sequence of events that leads to the crash:
fetchInitialState, which reads the last synced event ID from the database (e.g.25717039).START_STREAMmessage withlast_ack_event_id: 25717039.CONNECTED.idlestate and waits. After 20 seconds (theACK_TIMEOUT), it transitions toCONNECTED.checkingForMissedEventsto verify that no events were lost due to network issues.checkForMissedEventstries to readcontext.event.event.idto know which event ID to check from. However,context.eventisnullbecause no fullnode event was ever received in this session.Error('No event in context when checking for missed events'), which causes the state machine to transition toERRORand the daemon stops.The root cause is that
checkForMissedEventsassumescontext.eventhas been populated by a priorstoreEventaction, but this is not true when the daemon is fully synced and no events arrive beforeACK_TIMEOUTfires.The
startStreamaction already handles this case correctly by falling back tocontext.initialEventId:This fix applies the same pattern to
checkForMissedEvents: usecontext.event.event.idif available, otherwise fall back tocontext.initialEventId. It only throws if both are missing, which would indicate a real initialization problem.Acceptance Criteria
checkForMissedEventsshould usecontext.initialEventIdas a fallback whencontext.eventis nullChecklist
master, confirm this code is production-ready and can be included in future releases as soon as it gets merged