Guard desktop startup against legacy provider state#1027
Guard desktop startup against legacy provider state#1027Amer-alsayed wants to merge 3 commits intopingdotgg:mainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI 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)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
| if (normalizedLimit === 0) { | ||
| return Stream.empty; | ||
| } | ||
| const readPage = ( |
There was a problem hiding this comment.
🔴 Critical Layers/OrchestrationEventStore.ts:216
When a row fails decoding, its sequence is excluded from events, so the pagination cursor (events[events.length - 1]!.sequence) advances past only successfully decoded events. The next query fetches from that cursor, re-retrieving the failed row which fails decoding again, creating an infinite loop. For example: rows with sequences [1,2,3] are fetched, row 3 fails decoding, events becomes [{seq:1},{seq:2}], cursor becomes 2, next query refetches row 3, which fails again.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/server/src/persistence/Layers/OrchestrationEventStore.ts around line 216:
When a row fails decoding, its sequence is excluded from `events`, so the pagination cursor (`events[events.length - 1]!.sequence`) advances past only successfully decoded events. The next query fetches from that cursor, re-retrieving the failed row which fails decoding again, creating an infinite loop. For example: rows with sequences [1,2,3] are fetched, row 3 fails decoding, `events` becomes [{seq:1},{seq:2}], cursor becomes 2, next query refetches row 3, which fails again.
Evidence trail:
apps/server/src/persistence/Layers/OrchestrationEventStore.ts lines 230-241 (decode failure returns Option.none), lines 248-261 (pagination logic with cursor based on last successful event's sequence at line 258)
|
Updated pagination to advance using the last row sequence when skipping invalid events, preventing decode loops. Desktop WS URL IPC fix and legacy provider cleanup unchanged. Tests: bun fmt, bun lint, bun typecheck. |
What Changed
gemini) instead of failing startup.Why
Persisted legacy provider data can cause orchestration event decode failures at startup, which restarts the backend and leaves the UI stuck (e.g., Add project hangs). This keeps startup resilient and preserves UX while still logging the issue.
UI Changes
None.
Checklist
bun fmt,bun lint,bun typecheckNote
Guard desktop startup against legacy provider state and undecodable events
readFromSequencein OrchestrationEventStore.ts now skips individual decode failures (logging a warning) rather than failing the stream, and advances pagination based on the last row sequence instead of the last decoded event.getBindingin ProviderSessionDirectory.ts deletes and drops invalid provider sessions instead of propagating a decode error, preventing stale/legacy state from blocking startup.wsUrlsynchronously from the main process via a newdesktop:get-ws-urlIPC channel instead of reading from an environment variable, returningnullon failure.Macroscope summarized d226081.