fix: loops when processing event from staging area#246
Conversation
WalkthroughThe PR removes getNextStagedEventForRoom from EventStagingRepository and EventService, changes MissingEventService.fetchMissingEvent to return Promise, and updates StagingAreaService to parallelize missing-event fetching, refine authorization error conditions, and log payloads while marking events as unstaged on errors. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant SA as StagingAreaService
participant MS as MissingEventService
participant ES as EventService
participant L as Logger
C->>SA: process(event)
SA->>SA: identify dependencies (missing, authEvents)
par Parallel fetch of missing events
SA->>MS: fetchMissingEvent(dep1)
SA->>MS: fetchMissingEvent(dep2)
SA->>MS: fetchMissingEvent(...deps)
end
MS-->>SA: boolean results[]
SA->>SA: addedMissing = results contains true
alt Added missing auth event
SA->>SA: check authEvents ∩ missing
SA-->>C: throw MissingAuthorizationEventsError
else No blocking auth condition
SA-->>C: continue processing
end
rect rgba(255,230,230,0.5)
note over SA,ES: Error path
SA->>L: log "Error processing event" with payload
SA->>ES: markEventAsUnstaged(event)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧬 Code graph analysis (1)packages/federation-sdk/src/services/staging-area.service.ts (1)
🔇 Additional comments (6)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #246 +/- ##
=======================================
Coverage 81.84% 81.84%
=======================================
Files 63 63
Lines 4705 4705
=======================================
Hits 3851 3851
Misses 854 854 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary by CodeRabbit
Bug Fixes
Refactor