Exit on sync rule validation error #198
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.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:
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.