Improve error messages for Postgres query failures#620
Conversation
🦋 Changeset detectedLatest commit: 3e6a820 The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
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 |
|
Docs PR opened: powersync-ja/powersync-docs#416 Added entries for new Postgres replication error codes PSYNC_S1120 and PSYNC_S1121 to the error codes reference page. |
LucDeCaf
left a comment
There was a problem hiding this comment.
Looks good; I'll mention that there are still a couple raw db.query calls outside the module-postgres/src/replication folder, but I'm guessing those are outside the original intended scope of rquery and rstream. It might be worth expanding the scope of the function to also wrap those errors, but that would make the error codes less specific, i.e. Socket timed out while replicating -> Socket timed out. I could also see a future change adding something like pgquery for generic error messages. Just ideas to play around with.
|
Yeah, this focuses on the most important replication queries to start with. Postgres storage is specifically excluded for now - we'd want different error codes for those. There are also a couple of cases using But I think this should at least cover the most important cases that users are running into. |
This improves error messages for Postgres query failures to assist with debugging. Unfortunately we have to wrap every query invocation (or the entire client) to achieve this, but this PR covers most of them.
This introduces two new error codes for Postgres:
Before:
After:
There are still general log formatting issues here that make the output difficult to read, but at least the details are better:
[PSYNC_S1121] Socket timed out while replicatinginstead ofpostgres query lateSELECT * FROM \"public\".\"bulk_data\" WHERE \"id\" > $1 ORDER BY \"id\" LIMIT 10000