Skip to content

fix: rename UnhandledErrorType.FetchingOwnCapabilitiesOnNewActivity t…#229

Merged
szuperaz merged 4 commits intomainfrom
docs-snippet-updates
Feb 5, 2026
Merged

fix: rename UnhandledErrorType.FetchingOwnCapabilitiesOnNewActivity t…#229
szuperaz merged 4 commits intomainfrom
docs-snippet-updates

Conversation

@szuperaz
Copy link
Contributor

@szuperaz szuperaz commented Feb 4, 2026

…o UnhandledErrorType.FetchingOwnFieldsOnNewActivity

🎫 Ticket: a follow-up for https://linear.app/stream/issue/REACT-685/backfill-all-own-fields-from-ownbatch-request

📑 Docs: https://github.com/GetStream/docs-content/pull/990

💡 Overview

It renames the unhandled error type for failing to fetch own_capabilities, it's fine to rename this error, because it's not yet documented anywhere.

This PR also adds an automatic retry to state sync and ownCapabilities fetching, ensuring that unhandled errors are only thrown when necessary.

📝 Implementation notes

Summary by CodeRabbit

  • New Features

    • Added configurable retry/backoff for network operations to improve resilience.
  • Reliability Improvements

    • Improved reconnection and error handling, including health tracking and conditional reconciliation to reduce transient failures in feeds and notifications.
  • Tests

    • Expanded test coverage for retry logic, synchronization, pagination, notifications, and connection-change scenarios.

Note: No direct UI changes; primarily stability and reliability updates.

…o UnhandledErrorType.FetchingOwnFieldsOnNewActivity
@coderabbitai
Copy link

coderabbitai bot commented Feb 4, 2026

Warning

Rate limit exceeded

@szuperaz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Adds a retry utility and integrates it into feed synchronization and ownBatch calls; renames an unhandled error enum member; adds/updates retry-focused unit and integration tests and logging; modifies reconnection/reconciliation dispatch and a connection test timeout; and subscribes to unhandled errors in the sample React app.

Changes

Cohort / File(s) Summary
Retry utility & tests
packages/feeds-client/src/utils/retry.ts, packages/feeds-client/src/utils/retry.test.ts
New retry module (withRetry, isRetryableError, RetryOptions) and comprehensive tests covering backoff, retry decisions, default 4xx/5xx rules, timing and max-retries.
Feed synchronization & client calls
packages/feeds-client/src/feed/feed.ts, packages/feeds-client/src/feeds-client/feeds-client.ts, packages/feeds-client/src/feeds-client/feeds-client.test.ts, packages/feeds-client/src/feed/feed.test.ts
Wraps getOrCreate/ownBatch with withRetry, adds health counter, conditional reconnection dispatch (only when failures exist), and extensive tests for retry behavior (4xx vs 5xx, max retries, reset logic).
Event model rename
packages/feeds-client/src/common/real-time/event-models.ts
Renamed enum member FetchingOwnCapabilitiesOnNewActivityFetchingOwnFieldsOnNewActivity and updated discriminant string/value and references.
Integration test logging / minor test flow changes
packages/feeds-client/__integration-tests__/docs-snippets/comments.test.ts, packages/feeds-client/__integration-tests__/docs-snippets/feed.test.ts, packages/feeds-client/__integration-tests__/docs-snippets/notification-feed.test.ts
Added console.log statements and small test control-flow tweak in notification-feed test (getNextPage call); some tests capture and log returned responses.
Connection/reconciliation test timing
packages/feeds-client/__integration-tests__/connection-changed.test.ts
Increased poll timeout from 2000ms to 20000ms to accommodate retry/reconciliation timing and added explanatory comment.
Sample app: unhandled error handling
sample-apps/react-demo/app/ClientApp.tsx
New effect subscribing to client's unhandled errors: logs the error, disconnects the user, and reconnects using current user/token; subscription cleaned up on unmount.

Sequence Diagram(s)

sequenceDiagram
  participant Feed as Feed.synchronize
  participant Retry as withRetry
  participant HTTP as ownBatch / getOrCreate
  participant API as Stream API

  Feed->>Retry: provide request function
  Retry->>HTTP: invoke request (attempt 1)
  HTTP->>API: HTTP request
  API-->>HTTP: 5xx / network error
  HTTP-->>Retry: reject error
  alt isRetryable / shouldRetry true
    Retry-->>Retry: wait backoff
    Retry->>HTTP: invoke request (attempt N)
    HTTP->>API: HTTP request
    API-->>HTTP: success
    HTTP-->>Retry: resolve response
    Retry-->>Feed: return response
  else non-retryable (4xx) or max attempts reached
    Retry-->>Feed: throw error
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • isekovanic
  • arnautov-anton

Poem

"🐰 I retried a hop, then two, then three,
Backoffs hummed until the call set free,
Enums renamed, the tests keep pace,
Reconnects tidy up the race,
A happy rabbit hops — retry with glee!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: renaming UnhandledErrorType.FetchingOwnCapabilitiesOnNewActivity to FetchingOwnFieldsOnNewActivity, which is the primary code change in the PR.
Description check ✅ Passed The description follows the repository template with ticket reference, docs link, overview, and implementation notes. It explains the rename rationale and mentions the retry logic additions.
Linked Issues check ✅ Passed The PR implements the follow-up work related to REACT-685 by renaming the error type and adding retry logic for ownBatch requests and state synchronization as needed.
Out of Scope Changes check ✅ Passed All changes align with the stated objectives: error type renaming, retry logic implementation for ownBatch and feed sync, and test updates. Minor logging additions in test files support the main functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs-snippet-updates

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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@sample-apps/react-demo/app/ClientApp.tsx`:
- Around line 77-85: The effect listening to client.on('errors.unhandled') uses
CURRENT_USER but does not include it in the dependency array, causing a
react-hooks/exhaustive-deps lint error; update the useEffect that registers the
'errors.unhandled' handler (the effect referencing client?.on and calling
client?.disconnectUser() and client?.connectUser(CURRENT_USER,
CURRENT_USER.token)) to include CURRENT_USER in the dependency array, and while
there rename the callback parameter from "_" to a descriptive name like "error"
to clarify its purpose in the console.error call.

Comment on lines 77 to 85
useEffect(() => {
const off = client?.on('errors.unhandled', async (_) => {
console.error('errors.unhandled', _);
await client?.disconnectUser();
await client?.connectUser(CURRENT_USER, CURRENT_USER.token);
});

return () => off?.();
}, [client]);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add missing CURRENT_USER dependency to fix ESLint error and unblock the pipeline.

CURRENT_USER is referenced inside the effect callback but is not listed in the dependency array, causing the react-hooks/exhaustive-deps rule violation. Since CURRENT_USER is already memoized, adding it to the dependency array is safe and won't cause unnecessary effect re-runs.

Additionally, consider renaming _ to error since it's actually used in console.error.

🔧 Proposed fix
 useEffect(() => {
-  const off = client?.on('errors.unhandled', async (_) => {
-    console.error('errors.unhandled', _);
+  const off = client?.on('errors.unhandled', async (error) => {
+    console.error('errors.unhandled', error);
     await client?.disconnectUser();
     await client?.connectUser(CURRENT_USER, CURRENT_USER.token);
   });

   return () => off?.();
-}, [client]);
+}, [client, CURRENT_USER]);
🧰 Tools
🪛 ESLint

[error] 85-85: React Hook useEffect has a missing dependency: 'CURRENT_USER'. Either include it or remove the dependency array.

(react-hooks/exhaustive-deps)

🪛 GitHub Actions: Lint and test

[error] 85-85: React Hook useEffect has a missing dependency: 'CURRENT_USER'. Either include it or remove the dependency array. (react-hooks/exhaustive-deps)

🪛 GitHub Check: lint-and-test (22.x)

[failure] 85-85:
React Hook useEffect has a missing dependency: 'CURRENT_USER'. Either include it or remove the dependency array

🤖 Prompt for AI Agents
In `@sample-apps/react-demo/app/ClientApp.tsx` around lines 77 - 85, The effect
listening to client.on('errors.unhandled') uses CURRENT_USER but does not
include it in the dependency array, causing a react-hooks/exhaustive-deps lint
error; update the useEffect that registers the 'errors.unhandled' handler (the
effect referencing client?.on and calling client?.disconnectUser() and
client?.connectUser(CURRENT_USER, CURRENT_USER.token)) to include CURRENT_USER
in the dependency array, and while there rename the callback parameter from "_"
to a descriptive name like "error" to clarify its purpose in the console.error
call.

@szuperaz szuperaz merged commit 4f7e0d1 into main Feb 5, 2026
5 of 6 checks passed
@szuperaz szuperaz deleted the docs-snippet-updates branch February 5, 2026 10:19
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