Skip to content

fix(web): gracefully handle SchemaVersionNotSupported error in ZeroPr…#1460

Open
guangyang1206 wants to merge 1 commit into
MODSetter:devfrom
guangyang1206:fix/frontend-reloads-zero-cache-user-table-1355
Open

fix(web): gracefully handle SchemaVersionNotSupported error in ZeroPr…#1460
guangyang1206 wants to merge 1 commit into
MODSetter:devfrom
guangyang1206:fix/frontend-reloads-zero-cache-user-table-1355

Conversation

@guangyang1206
Copy link
Copy Markdown
Contributor

@guangyang1206 guangyang1206 commented Jun 2, 2026

PR: MODSetter/SurfSense #1355

Description

Added graceful handling for the SchemaVersionNotSupported error in the ZeroAuthSync component within ZeroProvider.tsx. When this error is detected, a sonner toast is shown to notify the user, and clear repair steps are logged to the console, while preventing infinite reconnection/page reload loops.

Motivation and Context

When the Zero Cache replica becomes out of sync with the Postgres publication (e.g., the user table is not included in zero_publication), the frontend Zero client receives a SchemaVersionNotSupported error. The default onUpdateNeeded handler calls location.reload(), causing the page to refresh infinitely every ~60 seconds. This fix prevents the bad user experience of constant page reloads and provides clear instructions for resolution.

Fixes #1355

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  1. Simulated the scenario where the user table is not in zero_publication
  2. Opened the frontend page
  3. Before the fix: The page automatically refreshed every ~60 seconds, with SchemaVersionNotSupported repeatedly appearing in the console
  4. After the fix: A toast notification is displayed, clear repair steps are logged to the console, and the page no longer refreshes infinitely
  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR adds graceful error handling for the SchemaVersionNotSupported error in the Zero sync provider to prevent infinite page reload loops. When the Zero Cache replica becomes out of sync with the Postgres publication, the system now displays a user-friendly toast notification and logs clear repair instructions instead of repeatedly refreshing the page every ~60 seconds. The fix uses a ref to track whether the error has been shown and only triggers the notification once until the connection is restored.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/components/providers/ZeroProvider.tsx

Need help? Join our Discord

…ovider

The SurfSense frontend reloaded every ~60s when the Zero Cache
replica was out of sync with the Postgres publication (e.g. the
`user` table was added to `zero_publication` but Zero Cache
wasn't notified to resync).

Zero's default `onUpdateNeeded` handler calls `location.reload()`,
causing an infinite reload loop.

This commit:
- Detects `SchemaVersionNotSupported` via `connectionState.name === 'error'`
- Shows a `sonner` toast with a clear fix command
- Logs a detailed message to the console with troubleshooting steps
- Uses a ref to prevent repeated toast notifications
- Does NOT trigger a reconnect loop for this fatal schema error

Fixes MODSetter#1355
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

@guangyang1206 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 69931051-2588-495c-896c-499ac55c60c3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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