-
Notifications
You must be signed in to change notification settings - Fork 11
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 error handling noise #3666
Conversation
🧪 Review environmenthttps://uedjhcfmmzotxpoaeldutnl5iy0bwnko.lambda-url.ca-central-1.on.aws/ |
@@ -30,7 +30,7 @@ export async function detectOldUnprocessedSubmissions( | |||
const diffMs = Math.abs(currentDate - current.createdAt); | |||
|
|||
// 86400000 milliseconds = 1 Day | |||
const diffDays = Math.ceil(diffMs / 86400000); | |||
const diffDays = Math.floor(diffMs / 86400000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely removing the logger configuration for |
But this comment assumes we are not catching auth errors or any unhandled errors anywhere in the application. Do you mean a different format of error logging that we might be missing? Keep in mind, AuthJs should not be swallowing the errors thrown by the framework. The logger configuration is optional and is usually enabled if we want to treat auth logs differently from the rest of the application. |
In testing I threw errors in the callbacks and events and they did not bubble up. This is because the |
@@ -175,11 +174,14 @@ export const { | |||
// account is only available on the first call to the JWT function | |||
if (account?.provider) { | |||
if (!token.email) { | |||
throw new Error(`JWT token does not have an email for user with name ${token.name}`); | |||
logMessage.error(`JWT token does not have an email for user with name ${token.name}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logs example when in production:
{"level":"error","time":1716406719058,"msg":"JWT token does not have an email for user with name Wissam Moussa"}
{"level":"error","time":1716406719058,"msg":"NextAuth error: {\"name\":\"s\",\"type\":\"CallbackRouteError\",\"kind\":\"error\",\"message\":\"Read more at https://errors.authjs.dev#callbackrouteerror\"}."}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary | Résumé
Fixes #3657 (The new version of NextAuth throws an error for any bad login attempt. This affects the MFA section)
This PR fine-tunes the AuthJs logger customization.
It also fixes a flaky test.