[ECO-5450] fix: async connection state transition side effects#1119
[ECO-5450] fix: async connection state transition side effects#1119
Conversation
|
""" WalkthroughThe changes introduce a Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ConnectionManager
participant Channel
Client->>ConnectionManager: close()
ConnectionManager->>ConnectionManager: set closeRequested = true
Client->>ConnectionManager: connect()
ConnectionManager->>ConnectionManager: check closeRequested or terminal state
alt closeRequested or terminal state
ConnectionManager->>ConnectionManager: reinitializeChannelsAfterReconnect()
end
ConnectionManager->>ConnectionManager: reset closeRequested
Client->>Channel: attach()
Channel->>Channel: transition to attaching
Channel->>Channel: transition to attached
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected. Possibly related PRs
Suggested reviewers
Poem
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings⏰ 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). (11)
🔇 Additional comments (1)
✨ 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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
sacOO7
left a comment
There was a problem hiding this comment.
not sure why integration tests are failing
8a895fc to
404a95a
Compare
Side effects for close and reconnect were invoked asynchronously on a different thread, so the sequence of operations: `client.close(); client.connect(); channel.attach();` produced unexpected results, with the channel ending up in the initialized state instead of attaching. To fix this, we now proactively reset the connection and channel states. If `connect()` is called while in a terminal state, we can synchronously clear channel states. Additionally, we need to handle the case where `close()` is called but the connection has not yet transitioned to the closing state, and `connect()` is invoked immediately afterward. In this situation, it is also safe to detach from channels and clean up their state.
404a95a to
31d1cbf
Compare
sacOO7
left a comment
There was a problem hiding this comment.
LGTM, you can double check for failing integration tests
- Ensure `msgSerial` is reset to `0` when reconnecting from the suspended state. - Added a unit test to verify this behavior.
Fix #1118
Side effects for close and reconnect were invoked asynchronously on a different thread, so the sequence of operations:
client.close(); client.connect(); channel.attach();produced unexpected results, with the channel ending up in the initialized state instead of attaching.To fix this, we now proactively reset the connection and channel states. If
connect()is called while in a terminal state, we can synchronously clear channel states.Additionally, we need to handle the case where
close()is called but the connection has not yet transitioned to the closing state, andconnect()is invoked immediately afterward. In this situation, it is also safe to detach from channels and clean up their state.Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Tests