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: Use consistent error type between doc, logger and error class #5046

Merged
merged 5 commits into from Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions docs/docs/errors.md
Expand Up @@ -76,7 +76,11 @@ Please check your OAuth provider and make sure your URLs and other options are

If you are using an OAuth v1 provider, check your OAuth v1 provider settings, especially the OAuth token and OAuth token secret.

#### CALLBACK_OAUTH_ERROR
3. `openid-client` version mismatch

If you are seeing `expected 200 OK with body but no body was returned`, it might have happened due to `openid-client` (which is peer dependency) node version mismatch. For instance, `openid-client` requires `>=14.2.0` for `lts/fermium` and has similar limits for the other versions. For the full list of the compatible node versions please see [package.json](https://github.com/panva/node-openid-client/blob/2a84e46992e1ebeaf685c3f87b65663d126e81aa/package.json#L78).

#### OAUTH_CALLBACK_ERROR

This can occur during the handling of the callback if the `code_verifier` cookie was not found or an invalid state was returned from the OAuth provider.

Expand Down Expand Up @@ -179,8 +183,3 @@ Useful links:
- https://next-auth.js.org/configuration/pages
- https://nextjs.org/docs/advanced-features/middleware#matcher

### Other

#### oauth_callback_error expected 200 OK with body but no body was returned

This error might happen with some of the providers. It happens due to `openid-client`(which is peer dependency) node version mismatch. For instance, `openid-client` requires `>=14.2.0` for `lts/fermium` and has similar limits for the other versions. For the full list of the compatible node versions please see [package.json](https://github.com/panva/node-openid-client/blob/2a84e46992e1ebeaf685c3f87b65663d126e81aa/package.json#L78)
4 changes: 0 additions & 4 deletions packages/next-auth/src/core/lib/oauth/callback.ts
Expand Up @@ -146,10 +146,6 @@ export default async function oAuthCallback(params: {
})
return { ...profileResult, cookies: resCookies }
} catch (error) {
logger.error("OAUTH_CALLBACK_ERROR", {
error: error as Error,
providerId: provider.id,
})
throw new OAuthCallbackError(error as Error)
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/next-auth/src/core/routes/callback.ts
Expand Up @@ -190,7 +190,10 @@ export default async function callback(params: {
}
} catch (error) {
if ((error as Error).name === "OAuthCallbackError") {
logger.error("CALLBACK_OAUTH_ERROR", error as Error)
logger.error("OAUTH_CALLBACK_ERROR", {
error: error as Error,
providerId: provider.id,
})
return { redirect: `${url}/error?error=OAuthCallback`, cookies }
}
logger.error("OAUTH_CALLBACK_ERROR", error as Error)
Expand Down