Skip to content

Conversation

@rkistner
Copy link
Contributor

Currently, if sync rules fail to validate (e.g. due to a SQL syntax error), a message is logged, and the error is otherwise ignored. This makes it easy to miss the issue, and not understand why the new sync rules are applied.

See the issue logged here: powersync-ja/powersync.dart#234

This changes the validation behavior to one of two options:

  1. exit_on_error: true (the default for self-hosting): The replication process will exit with an error on startup when the sync rules do not pass validation. This should be easy to detect during self-hosting.
  2. exit_on_error: false (will be used for cloud version): This loads the new sync rules file even if validation failed. The replication process will catch the error, and report it (1) in the logs every 30 seconds or so, and (2) in the diagnostics API, visible on the cloud dashboard.

The option is in the sync_rules section:

sync_rules:
  path: sync-rules.yaml
  exit_on_error: false

This new default exit_on_error: true behavior may be considered a breaking change for self-hosted, but would only apply when there is already a sync rules issue (and will now properly surface the issue), so I think it's worth making this breaking change.

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2025

🦋 Changeset detected

Latest commit: 95c62a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@powersync/service-module-postgres-storage Minor
@powersync/service-module-mongodb-storage Minor
@powersync/service-core-tests Minor
@powersync/service-module-postgres Minor
@powersync/service-module-mongodb Minor
@powersync/service-core Minor
@powersync/service-module-mysql Minor
@powersync/service-types Minor
@powersync/service-image Minor
test-client Patch
@powersync/lib-service-postgres Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner changed the title Improve sync rule error handling Exit on sync rule validation error Feb 10, 2025
Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

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

Looks good to me :)

@rkistner rkistner merged commit 4b43cdb into main Feb 10, 2025
15 checks passed
@rkistner rkistner deleted the report-sync-rule-errors branch February 10, 2025 11:00
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