electric-sql / electric

Sync little subsets of your Postgres data into local apps and services.
https://electric-sql.com
Apache License 2.0
6.47k stars 156 forks source link

feat: enable error handler to recover from failed HTTP requests #2011

Closed kevin-dp closed 1 day ago

kevin-dp commented 2 days ago

This PR modifies the onError handler that is supported by the shape stream such that it can recover from certain HTTP request errors. For example, if the HTTP request fails with a 401 because of an expired token, the handler could fetch a new token, and try again by returning the modified HTTP headers. The shapestream will then retry.

Accompanying docs PR: https://github.com/electric-sql/electric/pull/2018

KyleAMathews commented 2 days ago

Should we make the onError handler async such that it can for instance fetch the new token asynchronously?

yeah, that'll be a common requirement.

netlify[bot] commented 1 day ago

Deploy Preview for electric-next ready!

Name Link
Latest commit 0e9f64679df126499d0222fca1391abe9e8fa720
Latest deploy log https://app.netlify.com/sites/electric-next/deploys/673f43c7711aeb0008660b9d
Deploy Preview https://deploy-preview-2011--electric-next.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.