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
See: https://github.com/vercel/next.js/issues/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
Operation
s will be fulfilled with anOperationResult
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
errorQueue
config
is not initialized