fix: improve canceled order cleanup and timeout detection logic#264
fix: improve canceled order cleanup and timeout detection logic#264
Conversation
- Fix early return bug in _subscribeToPublicEvents that left _isProcessingTimeout=true permanently - Simplify timeout detection: remove timestamp comparison, use status-based logic - Separate cancellation logic from timeout logic for better reliability - Only delete sessions for pending/waiting canceled orders, preserve active canceled orders - Update documentation to reflect simplified detection mechanism
WalkthroughThe timeout and cancellation detection logic for order processing has been refactored to use status and state comparisons instead of timestamp-based checks. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant OrderNotifier
participant PublicEventStream
participant SessionManager
User->>OrderNotifier: Initiate sync()
OrderNotifier->>OrderNotifier: Check _isSyncing flag
alt Not syncing
OrderNotifier->>OrderNotifier: Set _isSyncing = true
OrderNotifier->>OrderNotifier: Iterate stored messages
OrderNotifier->>OrderNotifier: (Timeout cleanup removed)
OrderNotifier->>OrderNotifier: Complete sync
OrderNotifier->>OrderNotifier: Set _isSyncing = false
end
PublicEventStream->>OrderNotifier: New public event
OrderNotifier->>OrderNotifier: Check current state/session
OrderNotifier->>OrderNotifier: Set _isProcessingTimeout = true
alt Cancellation detected
alt State is pending/waiting
OrderNotifier->>SessionManager: Delete session
else Active state
OrderNotifier->>OrderNotifier: Update state to canceled
end
OrderNotifier->>User: Show cancellation notification
else Timeout detected (pending/waiting mismatch)
alt Maker
OrderNotifier->>OrderNotifier: Update state to pending, persist reversal
else Taker
OrderNotifier->>SessionManager: Delete session
end
OrderNotifier->>User: Show timeout notification
end
OrderNotifier->>OrderNotifier: Set _isProcessingTimeout = false
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)lib/**/*.dart📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
**/*.dart📄 CodeRabbit Inference Engine (CLAUDE.md)
Files:
🧠 Learnings (11)📓 Common learnings📚 Learning: 2025-06-26T15:03:23.529ZApplied to files:
📚 Learning: 2025-07-20T23:33:17.689ZApplied to files:
📚 Learning: 2025-08-03T09:43:38.727ZApplied to files:
📚 Learning: 2025-08-03T09:43:38.727ZApplied to files:
📚 Learning: 2025-06-04T19:35:20.209ZApplied to files:
📚 Learning: 2025-05-08T16:29:52.154ZApplied to files:
📚 Learning: 2025-05-06T15:49:55.079ZApplied to files:
📚 Learning: 2025-06-08T23:54:09.987ZApplied to files:
📚 Learning: 2025-05-06T15:49:26.443ZApplied to files:
📚 Learning: 2025-08-03T09:43:38.727ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
- Move critical validations before _isProcessingTimeout flag to prevent permanent blocking - Add Status.pending to cancellation detection filters in _subscribeToPublicEvents - Enable cleanup for pending→canceled orders that were previously ignored - Maintain separation between timeout logic (waiting states only) and cancellation logic
Summary by CodeRabbit
Bug Fixes
Documentation