Improve idle timer and connection log messages#2188
Improve idle timer and connection log messages#2188mattheworiordan wants to merge 1 commit intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
WalkthroughConnection logging and idle-timeout error messages updated: ConnectionManager now logs resumed vs reestablished connections and adds Ably-specific diagnostics for freshness checks; Transport produces an Ably-formatted idle-timeout disconnect ErrorInfo (code 80003, status 408) that can include the connectionId. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/common/lib/transport/connectionmanager.ts`:
- Around line 893-899: The freshness log message incorrectly states that the TTL
(connectionStateTtl) was exceeded while the actual check compares sinceLast
against connectionStateTtl + maxIdleInterval; update the log to reflect the true
threshold by including both connectionStateTtl and maxIdleInterval (or the
summed threshold) in the message where sinceLast, connectionStateTtl,
maxIdleInterval and connectionId are referenced so the log accurately reports
the expiry condition that triggered discarding the connection state.
- Around line 676-689: The log computes whether the connection "resumed" by
comparing prevConnId to connectionId, but prevConnId is read after a possible
setConnection(...) mutation in ConnectionManager.activateTransport(), causing
reestablish events to be mislabeled as resumed; fix by capturing the existing
connectionId into a local variable (e.g., prevConnId) before any call that may
update the manager state (before setConnection/updateConnectionId), then compute
resumed = prevConnId === connectionId and use that stored prevConnId in the
Logger.logAction call so the log reflects the pre-update connection id.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7a727441-bd8e-427f-9470-3b7777ff6243
📒 Files selected for processing (2)
src/common/lib/transport/connectionmanager.tssrc/common/lib/transport/transport.ts
Add connection ID, error codes, and actionable context to connection lifecycle log messages. The idle timer expiry now explains what will happen next (disconnect + reconnect) and includes the error code 80003. A new LOG_MINOR message logs when the connection is resumed or reestablished after disconnection, providing a bookend to the idle expiry message. The connection state freshness check now explains consequences (new connection, channel reattach) and includes the connection state TTL and connection ID. Also replace "realtime" with "Ably" in user-facing log messages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a134e70 to
90bc0ad
Compare
Summary
When running Ably in a server-side environment (e.g. Temporal durable execution where connections are long-lived and transported), I started seeing repeated idle timer error log messages like:
These are confusing for developers because:
Note: I believe these disconnects are expected, they are probably triggered by me opening & closing my laptop
As we think about how Ably is increasingly used server-side, these messages need to be more useful. This is a quick win to make the logs actionable.
Changes
Test plan
idle_transport_timeouttest passes🤖 Generated with Claude Code
Summary by CodeRabbit