Skip to content

docs(websocket): fix dead-socket watchdog anchor description - #393

Merged
jlucaso1 merged 4 commits into
mainfrom
claude/nifty-bohr-uvzt5k
Jul 7, 2026
Merged

docs(websocket): fix dead-socket watchdog anchor description#393
jlucaso1 merged 4 commits into
mainfrom
claude/nifty-bohr-uvzt5k

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

What

Updates the "Dead socket detection" section of advanced/websocket-handling.mdx to reflect whatsapp-rust#995.

Why

That PR fixed a bug where the dead-socket watchdog was anchored to the most recent send (last_data_sent_ms), which let continued outgoing traffic (messages, receipts, presence) keep pushing the 20s deadline forward and mask a half-open socket indefinitely. The fix anchors the watchdog to SessionStats::first_send_since_recv_ms — the first send since the last receive — matching WA Web's deadSocketTimer.onOrBefore semantics, which keep the earliest armed deadline rather than the most recent one.

The docs previously described the pre-fix (buggy) behavior:

  • "Fires if DEAD_SOCKET_TIME (20s) has elapsed since the last send with no receive"
  • "checking is_dead_socket(last_sent, last_recv) unconditionally each iteration"

Changes

  • advanced/websocket-handling.mdx:
    • Corrected the "Dead socket detection" bullets and the DEAD_SOCKET_TIME constant description to describe the anchor (first send since last receive) rather than the last send.
    • Explained why the anchor doesn't move on subsequent sends, and reference the new SessionStats::first_send_since_recv_ms field.
    • Updated the WA Web comparison to deadSocketTimer.onOrBefore and the is_dead_socket(first_send_since_recv, last_recv) call signature.

No other docs needed updates — this PR is internal to the keepalive/reconnect implementation with no public API changes.


Generated by Claude Code


Summary by cubic

Fixes dead-socket detection docs to anchor the watchdog to the first send since the last receive, not the most recent send, matching WA Web’s deadSocketTimer.onOrBefore. Updates DEAD_SOCKET_TIME wording to keep the earliest deadline, aligns concepts/architecture.mdx to reference first_send_since_recv_ms, and clarifies the dead-socket bullet so “triggering immediate reconnection” modifies the correct clause.

Written for commit a1a3129. Summary will update on new commits.

jlucaso1 added 2 commits July 6, 2026 23:27
Reflects whatsapp-rust#995: the watchdog is armed on the first send
since the last receive, not the most recent send.
@mintlify

mintlify Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
whatsapp-rust 🟢 Ready View Preview Jul 7, 2026, 2:33 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jlucaso1, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 30 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 42f2960d-39f1-45c3-b8e1-2b010cc2c30c

📥 Commits

Reviewing files that changed from the base of the PR and between 288952e and a1a3129.

📒 Files selected for processing (2)
  • advanced/websocket-handling.mdx
  • concepts/architecture.mdx

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR corrects documentation for the dead-socket watchdog to reflect the bug fix in whatsapp-rust#995, where the watchdog anchor was changed from last_data_sent_ms (most recent send) to SessionStats::first_send_since_recv_ms (first send since the last receive).

  • advanced/websocket-handling.mdx: Rewrites the "Dead socket detection" section with accurate bullets, a detailed explanation of record_frame_sent's conditional arming logic, and an updated WA Web comparison referencing deadSocketTimer.onOrBefore and the corrected is_dead_socket(first_send_since_recv, last_recv) call signature.
  • concepts/architecture.mdx: Adds first_send_since_recv_ms to the atomic-timestamps list and updates the keepalive behavior bullet to match, keeping both files in sync.

Confidence Score: 5/5

Documentation-only update that accurately reflects an already-merged implementation change; no runtime code is touched.

Both changed files are .mdx documentation. The description of the new first_send_since_recv_ms anchor is internally consistent across the two files and accurately matches the behavior described in the referenced implementation PR. The last_data_sent_ms field is correctly retained for telemetry alongside the new anchor field. No code paths, APIs, or configurations are affected.

No files require special attention.

Important Files Changed

Filename Overview
advanced/websocket-handling.mdx Updates 'Dead socket detection' section to describe the new first_send_since_recv_ms anchor, corrects DEAD_SOCKET_TIME description, and adds a detailed prose paragraph explaining the pre-fix vs post-fix behavior difference.
concepts/architecture.mdx Adds first_send_since_recv_ms to the atomic-timestamps list and updates the dead-socket detection bullet to reference the new anchor and deadSocketTimer.onOrBefore, consistent with the websocket-handling.mdx update.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A([Keepalive tick]) --> B{anchor ==\nfirst_send_since_recv_ms}
    B -->|anchor == 0| C[Watchdog NOT armed\nNothing sent since last receive]
    B -->|anchor > 0| D{now - anchor\n>= 20s ?}
    D -->|No| E[Watchdog running,\nstill within deadline]
    D -->|Yes| F[DEAD SOCKET\nreconnect_immediately]

    G([Frame received]) --> H[Reset anchor to 0\nWatchdog cancelled]
    I([Frame sent]) --> J{anchor == 0 OR\nanchor <= last_recv ?}
    J -->|Yes| K[Arm watchdog:\nanchor = now]
    J -->|No| L[Anchor unchanged\nKeep earliest deadline]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A([Keepalive tick]) --> B{anchor ==\nfirst_send_since_recv_ms}
    B -->|anchor == 0| C[Watchdog NOT armed\nNothing sent since last receive]
    B -->|anchor > 0| D{now - anchor\n>= 20s ?}
    D -->|No| E[Watchdog running,\nstill within deadline]
    D -->|Yes| F[DEAD SOCKET\nreconnect_immediately]

    G([Frame received]) --> H[Reset anchor to 0\nWatchdog cancelled]
    I([Frame sent]) --> J{anchor == 0 OR\nanchor <= last_recv ?}
    J -->|Yes| K[Arm watchdog:\nanchor = now]
    J -->|No| L[Anchor unchanged\nKeep earliest deadline]
Loading

Reviews (3): Last reviewed commit: "docs(architecture): fix dangling modifie..." | Re-trigger Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Jul 7, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Confidence score: 5/5

  • In advanced/websocket-handling.mdx, the dead-socket explanation appears to conflict with the architecture summary (including the watchdog anchor to SessionStats::first_send_since_recv_ms), which could confuse readers about the actual timeout behavior and lead to incorrect implementations — align the two docs’ watchdog description before merging.

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread advanced/websocket-handling.mdx
…v_ms anchor

Addresses cubic-dev-ai review comment on PR #393 — the architecture
summary still described the pre-#995 last_data_sent_ms/"20s after a
send" model, contradicting the corrected websocket-handling.mdx page.
@greptile-apps
greptile-apps Bot dismissed their stale review July 7, 2026 02:38

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

jlucaso1 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Good catch — concepts/architecture.mdx's "Keepalive loop" summary still described the pre-#995 last_data_sent_ms/"20s after a send" model, contradicting the corrected websocket-handling.mdx page. Fixed in 6be476f: the shared-timestamps list and the dead-socket bullet now both reference first_send_since_recv_ms and match WA Web's deadSocketTimer.onOrBefore semantics.


Generated by Claude Code

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

greptile-apps[bot]
greptile-apps Bot previously approved these changes Jul 7, 2026
Addresses greptile-apps readability nit — "triggering immediate
reconnection" now attaches to "Detects dead socket" instead of reading
as attached to the "subsequent sends" clause.
@greptile-apps
greptile-apps Bot dismissed their stale review July 7, 2026 02:42

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Auto-approved: Documentation-only fixes correcting dead-socket watchdog anchor description. No code, config, or logic changes. Low impact and safe.

Re-trigger cubic

@jlucaso1
jlucaso1 merged commit a0c94d6 into main Jul 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant