fix(web): gracefully handle SchemaVersionNotSupported error in ZeroPr…#1460
Conversation
…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
|
@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. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR: MODSetter/SurfSense #1355
Description
Added graceful handling for the
SchemaVersionNotSupportederror in theZeroAuthSynccomponent withinZeroProvider.tsx. When this error is detected, asonnertoast 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
usertable is not included inzero_publication), the frontend Zero client receives aSchemaVersionNotSupportederror. The defaultonUpdateNeededhandler callslocation.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
Change Type
Testing Performed
usertable is not inzero_publicationSchemaVersionNotSupportedrepeatedly appearing in the consoleChecklist
High-level PR Summary
This PR adds graceful error handling for the
SchemaVersionNotSupportederror 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
surfsense_web/components/providers/ZeroProvider.tsx