-
Notifications
You must be signed in to change notification settings - Fork 432
chore: remove unnecessary error logs #2179
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
Conversation
"The access token has expired and there was an error while trying to refresh it.", | ||
new OAuth2Error({ | ||
code: e.error, | ||
message: e.error_description | ||
}) |
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.
Rather than logging the error, the cause is added to the error that is returned to the caller. At that point they can handle the error and choose to log or not.
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.
I still feel like it's unfortunate that we lose track of the entire stack trace, is there a way we can retain that? Typically, the cause is set to the original error: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
httpResponse | ||
); | ||
} catch (err: any) { | ||
console.error(err); |
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.
We are already returning the cause
to the caller here so the error log is not necessary,
await this.discoverAuthorizationServerMetadata(); | ||
|
||
if (discoveryError) { | ||
console.error(discoveryError); |
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.
This was a redundant log since we already log an error in discoverAuthorizationServerMetadata
.
await this.discoverAuthorizationServerMetadata(); | ||
|
||
if (discoveryError) { | ||
console.error(discoveryError); |
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.
This was a redundant log since we already log an error in discoverAuthorizationServerMetadata
.
} catch (e) { | ||
console.error( | ||
`An error occured while performing the discovery request. Please make sure the AUTH0_DOMAIN environment variable is correctly configured — the format must be 'example.us.auth0.com'. issuer=${issuer.toString()}, error:`, | ||
`An error occured while performing the discovery request. issuer=${issuer.toString()}, error:`, |
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.
This should rarely show up (e.g.: outages or misconfigurations) so I opted to keep this log in to provide some visibility since the errors are not always available for a caller to handler programmatically.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2179 +/- ##
=======================================
Coverage 82.87% 82.88%
=======================================
Files 21 21
Lines 2091 2092 +1
Branches 372 372
=======================================
+ Hits 1733 1734 +1
Misses 351 351
Partials 7 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
📋 Changes
There are a few cases where we log an error to the console where the necessary context is already in the error returned to the caller for handling. In the places this was not the case, the
cause
was added and made available to the caller.📎 References
Fixes: #2107