You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the instanceof operator against the AccessTokenError constructor always returns false, even if the object that is being tested is actually an instance of AccessTokenError.
This is an issue introduced by nextjs-auth0v1.5.0.
Reproduction
With nextjs-auth0v1.4.2 I'm able to check if an error occurred inside a NextJS API handler is an instance of AccessTokenError by doing so:
import{getAccessToken}from'@auth0/nextjs-auth0';import{AccessTokenError}from'@auth0/nextjs-auth0/dist/utils/errors';import{ApiError}from'src/lib/apiClient';try{consttokenInfo=awaitgetAccessToken(req,res);// ...}catch(err: any){// Re-throw an API error in a more convenient formatthrownewApiError({// Decide what status to return depending on the type of exception that was thrownstatus: errinstanceofAccessTokenError ? 401 : 500,message: `Code: ${err?.code}, Message: ${err?.message}.`,});}
With nextjs-auth0v1.5.0, I always get a 500 error because errors thrown by getAccessToken are always an instance of Error, instead AccessTokenError.
At least, this is the reason why our unit test on that API endpoint handler is currently failing.
Environment
Library version: v1.5.0
Platform: macOS Big Sur
Languages: Node v14.15.4, TS 4.4.4 (target ES6)
Other modules/plugins/libraries that might be involved: Jest 26.6.3
The text was updated successfully, but these errors were encountered:
Description
Using the instanceof operator against the
AccessTokenError
constructor always returns false, even if the object that is being tested is actually an instance ofAccessTokenError
.This is an issue introduced by
nextjs-auth0
v1.5.0.Reproduction
With
nextjs-auth0
v1.4.2 I'm able to check if an error occurred inside a NextJS API handler is an instance ofAccessTokenError
by doing so:With
nextjs-auth0
v1.5.0, I always get a 500 error because errors thrown bygetAccessToken
are always an instance ofError
, insteadAccessTokenError
.At least, this is the reason why our unit test on that API endpoint handler is currently failing.
Environment
The text was updated successfully, but these errors were encountered: