Skip to content

docs: 429 stream error now dispatches StreamError event - #506

Merged
jlucaso1 merged 8 commits into
mainfrom
claude/nifty-bohr-e7251y
Aug 10, 2026
Merged

jlucaso1 merged 8 commits into
mainfrom
claude/nifty-bohr-e7251y

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

whatsapp-rust #1263 changed handle_stream_error so that a 429 (rate-limited) <stream:error> now dispatches Event::StreamError in addition to the existing extended-backoff behavior — previously no event was emitted for 429, only the internal Fibonacci backoff counter was bumped. WhatsApp Web itself gives no UI signal for this case (its handler only special-cases the 500..600 range), but an embedder has no UI to fall back on, so 429 is now reported the same way every other coded stream error is.

Three docs described the old (no-event) behavior for code 429 and are updated here to match:

  • advanced/websocket-handling.mdx — "Error code behavior" table: 429 row's Event column changed from None to `StreamError`, plus a sentence added to the Fibonacci backoff section noting the new dispatch and linking PR #1263.
  • api/client.mdx — "Stream error handling" table: 429 row's Event emitted column changed from None (emits `Disconnected`) to `StreamError`, plus a new paragraph under "Rate limiting (429)" explaining the change.
  • concepts/events.mdxStreamError event's "Emitted" description and the "recognized codes" bullet list updated: 429 no longer says "no event emitted"; it now documents that StreamError fires for 429 same as unrecognized codes.

No other content in these files was touched, and nothing under changelog/ was modified.

Test plan

  • Verified all three files against the intended edits (diffed pushed content against source) — no changes beyond the targeted replacements.
  • N/A — documentation-only change, no build/test suite applies.

Generated by Claude Code


Summary by cubic

Docs now reflect that a 429 <stream:error> emits Event::StreamError (and then Event::Disconnected) while still using extended backoff (+5), matching whatsapp-rust PR #1263. Updated advanced/websocket-handling.mdx, api/client.mdx, and concepts/events.mdx to make 429 observable, merge StreamError emission cases into one lead sentence, and tighten wording.

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

Summary by CodeRabbit

  • Bug Fixes

    • Rate-limited stream errors (HTTP 429) now emit a StreamError event in addition to triggering reconnect backoff.
  • Documentation

    • Updated stream error and rate-limiting guidance to reflect the emitted event and five-step Fibonacci backoff behavior.

@mintlify

mintlify Bot commented Aug 10, 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 Aug 10, 2026, 2:53 AM

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

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The documentation now states that HTTP 429 stream errors emit Event::StreamError and retain the existing five-step Fibonacci reconnect backoff.

Changes

429 stream-error behavior

Layer / File(s) Summary
Document 429 event and reconnect behavior
concepts/events.mdx, api/client.mdx, advanced/websocket-handling.mdx
The documentation states that HTTP 429 stream errors emit Event::StreamError and increase reconnect backoff before reconnecting.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: cubic-dev-ai, greptile-apps

Poem

A rabbit checks the stream at dawn,
Finds 429, then hops along.
An error event now tells the tale,
While Fibonacci slows the trail.
The docs record each careful turn.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main documentation change for 429 stream errors.

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 Aug 10, 2026

Copy link
Copy Markdown

Greptile Summary

The PR updates documentation to reflect that rate-limited 429 stream errors now emit Event::StreamError while retaining extended Fibonacci backoff and subsequent disconnection behavior.

  • Aligns the WebSocket handling table and backoff explanation with the new event dispatch.
  • Updates the Client API’s 429 event sequence and rate-limiting guidance.
  • Revises the event reference and example wording for StreamError.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
advanced/websocket-handling.mdx Updates the 429 stream-error event and backoff documentation consistently.
api/client.mdx Documents the StreamError followed by Disconnected event sequence for 429 responses.
concepts/events.mdx Adds 429 to the documented StreamError emission behavior and generalizes the usage example.

Reviews (5): Last reviewed commit: "docs: merge StreamError emission cases i..." | Re-trigger Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 10, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
concepts/events.mdx (1)

484-488: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Correct the contradictory StreamError note.

The note says recognized codes emit specific events instead of StreamError, but the next row documents 429 as StreamError. Readers could ignore the 429 event. Change the introductory sentence so it describes explicit handling without excluding StreamError.

Proposed wording
-Recognized stream error codes emit specific events instead of `StreamError`:
+Specific stream error codes have the following event behavior:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@concepts/events.mdx` around lines 484 - 488, Update the introductory sentence
in the recognized stream error codes note to describe explicit event handling
without stating that these codes emit events instead of StreamError; preserve
the existing 401, 409, and 429 mappings unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@advanced/websocket-handling.mdx`:
- Line 1122: Rewrite the rate-limit backoff sentence in active voice by making
the client the subject that increments the backoff counter by 5 before the
normal increment; preserve the existing behavior and surrounding explanation.

In `@api/client.mdx`:
- Around line 512-513: Update the Event::StreamError reference in the client
documentation to use the documented tuple-variant pattern,
Event::StreamError(err), matching the StreamError(StreamError) definition in
concepts/events.mdx. Keep the surrounding explanation of code 429 behavior
unchanged.

In `@concepts/events.mdx`:
- Line 466: Update the emission description around the “Emitted” text so it
states that the client reports a 429 error, rather than saying 429 is reported.
Preserve the established third-person system-description style and the existing
explanation for unrecognized stream error codes.

---

Outside diff comments:
In `@concepts/events.mdx`:
- Around line 484-488: Update the introductory sentence in the recognized stream
error codes note to describe explicit event handling without stating that these
codes emit events instead of StreamError; preserve the existing 401, 409, and
429 mappings unchanged.
🪄 Autofix

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: ASSERTIVE

Plan: Pro Plus

Run ID: 5cc569f2-6a6e-4386-b97e-bff6ecc4f128

📥 Commits

Reviewing files that changed from the base of the PR and between 1ac6cb5 and a0192a0.

📒 Files selected for processing (3)
  • advanced/websocket-handling.mdx
  • api/client.mdx
  • concepts/events.mdx

Comment thread advanced/websocket-handling.mdx Outdated
Comment thread api/client.mdx Outdated
Comment thread concepts/events.mdx Outdated

@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.

All reported issues were addressed across 3 files

You’re at about 96% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

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

Re-trigger cubic

Comment thread api/client.mdx Outdated
@greptile-apps
greptile-apps Bot dismissed their stale review August 10, 2026 02:59

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

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0192a0f08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread api/client.mdx Outdated
Comment thread concepts/events.mdx Outdated
Comment thread api/client.mdx Outdated
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 10, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review August 10, 2026 03:01

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ce604fab6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread concepts/events.mdx Outdated
### StreamError

**Emitted:** For unrecognized stream error codes (codes not matching 401, 409, 429, 503, 515, or 516)
**Emitted:** For a `429` (rate-limited) stream error, and for unrecognized stream error codes (codes not matching 401, 409, 503, 515, or 516). Since [#1263](https://github.com/oxidezap/whatsapp-rust/pull/1263), the client reports 429 the same way as every other coded branch — WhatsApp Web's own handler has no arm for it either (only `500..600` is special-cased there), so this is an embedder-facing choice rather than a fidelity fix.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep 429 out of the unrecognized-code definition

The parenthetical now defines an unrecognized code as any code not matching 401, 409, 503, 515, or 516, which makes 429 satisfy that definition even though this sentence and the list below treat it as a specific rate-limit case. Retain 429 in the exclusion list while separately noting that it emits the generic StreamError event.

Useful? React with 👍 / 👎.

Comment thread concepts/events.mdx
- **401** → `LoggedOut` (session invalidated)
- **409** → `StreamReplaced` (another client connected)
- **429** → No event emitted (reconnects with extended backoff)
- **429** → `StreamError` (rate limited; also reconnects with extended backoff)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the example that labels every StreamError unknown

Once 429 reaches this event, the unchanged usage example above prints Unknown stream error for a known rate-limit condition. Consumers who copy the example will therefore misclassify 429s in their logs; use a neutral label or branch on err.code before describing the event as unknown.

Useful? React with 👍 / 👎.

Comment thread api/client.mdx Outdated

When the server returns a 429 stream error, the client bumps the internal backoff counter by 5 Fibonacci steps before reconnecting. This means the reconnection delay jumps significantly (e.g., from ~1s to ~13s on the first rate limit) to respect the server's throttling.

As of [#1263](https://github.com/oxidezap/whatsapp-rust/pull/1263), the client also dispatches an `Event::StreamError` (code `"429"`) — WhatsApp Web itself gives no signal for this case (its handler only special-cases `500..600`), but an embedder has no UI to fall back on, so a rate-limited session is now observable the same way every other coded stream error is. This is in addition to, not instead of, the `Event::Disconnected` the shared connection-loss path already dispatches once the socket actually closes — the 429 handler never marks the disconnect as expected, so it takes the same route every other unexpected drop does.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Split the rate-limit explanation into concise sentences

The added paragraph packs change history, WhatsApp Web behavior, embedder rationale, event ordering, and reconnect semantics into two long sentences. Split these into single-idea sentences so the event contract remains easy to scan and complies with the repository's explicit concise-sentence standard.

AGENTS.md reference: AGENTS.md:L25-L25

Useful? React with 👍 / 👎.

@greptile-apps
greptile-apps Bot dismissed their stale review August 10, 2026 03:07

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 10, 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.

All reported issues were addressed across 3 files (changes from recent commits).

You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread concepts/events.mdx Outdated
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@greptile-apps
greptile-apps Bot dismissed their stale review August 10, 2026 03:15

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).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Auto-approved: Docs-only PR updating three pages to reflect that a 429 stream error now emits StreamError; no code or behavior change here, and no public-contract or operational tradeoff requiring human judgment.

Re-trigger cubic

@jlucaso1
jlucaso1 merged commit eb1abc7 into main Aug 10, 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.

2 participants