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

fix(auth): Catch unexpected errors during initialization #3343

Merged
merged 4 commits into from
Jul 28, 2023

Conversation

kitten
Copy link
Member

@kitten kitten commented Jul 28, 2023

See: vercel/next.js#49373

Summary

It's unexpected and undefined behaviour to throw/reject in the initialization function passed to the authExchange() and any rejections will be uncaught.
This can make thes situations hard to debug, as the promise will be uncaught.

Instead, errors during initialization will now be caught, queued up Operations will be fulfilled with an OperationResult with their error populated to the caught error, and a warning will be output in development that tells users what's going on.

This essentially allows uncaught errors in the initialization function to be discovered and handled properly. At worst, it'll fail all operations coming in and will retry the initialization function if the operations are retried.

Set of changes

  • Catch initialization function and pass error to errorQueue
  • Retry initialization function if config is not initialized
  • Add warning for failing initialization function elaborating that they're unexpected
  • Add test

@kitten kitten changed the title Fix/auth handle init rejections fix(auth): Catch unexpected errors during initialization Jul 28, 2023
@kitten kitten merged commit 51f67ad into main Jul 28, 2023
6 checks passed
@kitten kitten deleted the fix/auth-handle-init-rejections branch July 28, 2023 13:15
This was referenced Jul 28, 2023
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.

1 participant