Skip to content

Conversation

@KyleAMathews
Copy link
Contributor

  • Add critical information that returning empty object {} is required to continue syncing
  • Document that returning void/undefined stops syncing permanently
  • Add comprehensive examples showing retry patterns:
    • Basic retry on server errors
    • Async token refresh on 401
    • Updating query parameters on 403
    • Selective retry logic with counters
  • Improve JSDoc with inline examples
  • Add clear behavior table for return values
  • Enhance error type documentation with properties

Fixes issue where users didn't know they must return at least {} to keep syncing, causing accidental stream termination when just logging errors.

🤖 Generated with Claude Code

- Add critical information that returning empty object `{}` is required to continue syncing
- Document that returning void/undefined stops syncing permanently
- Add comprehensive examples showing retry patterns:
  - Basic retry on server errors
  - Async token refresh on 401
  - Updating query parameters on 403
  - Selective retry logic with counters
- Improve JSDoc with inline examples
- Add clear behavior table for return values
- Enhance error type documentation with properties

Fixes issue where users didn't know they must return at least `{}` to keep syncing,
causing accidental stream termination when just logging errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.60%. Comparing base (656c344) to head (9e4cc0a).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3335      +/-   ##
==========================================
- Coverage   69.65%   69.60%   -0.06%     
==========================================
  Files         178      178              
  Lines        9709     9709              
  Branches      336      333       -3     
==========================================
- Hits         6763     6758       -5     
- Misses       2944     2949       +5     
  Partials        2        2              
Flag Coverage Δ
elixir 66.69% <ø> (-0.06%) ⬇️
elixir-client 73.94% <ø> (-0.53%) ⬇️
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/typescript-client 94.30% <ø> (ø)
packages/y-electric 55.12% <ø> (ø)
postgres-140000 65.81% <ø> (-0.04%) ⬇️
postgres-150000 65.83% <ø> (ø)
postgres-170000 65.65% <ø> (-0.15%) ⬇️
postgres-180000 65.87% <ø> (+0.06%) ⬆️
sync-service 65.97% <ø> (-0.02%) ⬇️
typescript 87.25% <ø> (ø)
unit-tests 69.60% <ø> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Added explicit statement that without an onError handler, any error will
stop syncing permanently with no automatic retry behavior.

This clarifies a potential misconception that there might be some default
retry logic even without onError.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@netlify
Copy link

netlify bot commented Oct 23, 2025

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 45c4cfb
🔍 Latest deploy log https://app.netlify.com/projects/electric-next/deploys/68fa574827649e0008c2214d
😎 Deploy Preview https://deploy-preview-3335--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

IMPORTANT FIX: The previous commit incorrectly stated that there's no
automatic retry without onError. This is wrong!

The client DOES automatically retry with exponential backoff:
- 5xx server errors → automatic retry
- Network errors → automatic retry
- 429 rate limits → automatic retry
- 4xx client errors (except 429) → NO retry, onError invoked immediately

The onError callback is only invoked:
1. After automatic retries are exhausted (for 5xx/network)
2. Immediately for non-retryable errors (4xx client errors)

Updated all documentation to reflect this, and revised examples to show
realistic use cases (mainly handling 4xx errors like 401 auth refresh).

Thanks to reviewer for catching this critical error!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@netlify
Copy link

netlify bot commented Oct 23, 2025

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 9e4cc0a
🔍 Latest deploy log https://app.netlify.com/projects/electric-next/deploys/68fa80045ed30b0008f24613
😎 Deploy Preview https://deploy-preview-3335--electric-next.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Fixed critical bug in the onError callback:
- Changed from throwing error (which crashes the stream) to proper return values
- Return void to stop on 4xx client errors (except 401/403)
- Return {} to retry on network errors
- Added comment clarifying 5xx errors are auto-retried
- Maintains proper 401/403 token refresh behavior

Before: throw error would crash the stream
After: Proper return values control retry/stop behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Added comprehensive section on handling authentication errors with onError:
- Complete example showing 401 token refresh
- 403 forbidden handling
- Proper return values for retry/stop behavior
- Clarification that 5xx errors are auto-retried
- Links to main onError documentation

This complements the gatekeeper-auth example and provides inline
documentation for the common auth error handling patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
The gatekeeper-auth example is already embedded in the auth guide
via <<< @../../examples/gatekeeper-auth/client/index.ts, which
shows the onError handling pattern. No need for a duplicate example.

The embedded example was already improved to show proper return values.
Added focused section on handling auth errors with onError that applies
to both proxy and gatekeeper patterns. The proxy auth example doesn't
show error handling, and this provides context for the embedded
gatekeeper example.

Kept it concise with just 401 token refresh example and links to full
TypeScript client docs for complete error handling details.
Copy link
Contributor

@thruflo thruflo left a comment

Choose a reason for hiding this comment

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

Great stuff 👍

@KyleAMathews KyleAMathews merged commit 4efdd11 into main Nov 4, 2025
44 checks passed
@KyleAMathews KyleAMathews deleted the claude/improve-typescript-onerror-011CUQRudRY67rXtM3eqhNju branch November 4, 2025 00:55
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.

4 participants