Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: update gatekeeper auth client to use onError. #2028

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

thruflo
Copy link
Contributor

@thruflo thruflo commented Nov 21, 2024

This is what I requested in #2018 (comment)

The client now uses the new onError to handle 401/403 and reconnect with a new auth token.

One observation: with the onError being defined before the shape is instantiated, I'm not sure what the best control flow is to handle a 405 must refetch. Certainly it's hard to handle in the onError callback. I guess this is what's being discussed in #1997 etc.

Copy link

netlify bot commented Nov 21, 2024

Deploy Preview for electric-next ready!

Name Link
🔨 Latest commit 65269be
🔍 Latest deploy log https://app.netlify.com/sites/electric-next/deploys/673f71e2f222740008457bd7
😎 Deploy Preview https://deploy-preview-2028--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.

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Nov 21, 2024

409 must-refetch responses never would reach onError

if (e.status == 409) {
// Upon receiving a 409, we should start from scratch
// with the newly provided shape handle
const newShapeHandle = e.headers[SHAPE_HANDLE_HEADER]
this.#reset(newShapeHandle)
await this.#publish(e.json as Message<T>[])
continue

@thruflo
Copy link
Contributor Author

thruflo commented Nov 21, 2024

So the stream handles it and the shape gets the instruction in a control message?

Makes sense, cool.

@KyleAMathews
Copy link
Contributor

So the stream handles it and the shape gets the instruction in a control message?

yeah exactly — the shape just resets its materialized view and recreates it — subscribers would never notice

@thruflo thruflo merged commit 6b83d15 into main Nov 22, 2024
26 of 27 checks passed
@thruflo thruflo deleted the thruflo/update-gatekeeper-client branch November 22, 2024 12:52
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