-
Notifications
You must be signed in to change notification settings - Fork 160
fix(cache): make dummy cache error ignorable #641
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
All "dummy" cache methods throw by design. This PR makes the corresponding errors ignorable so that the logs are less verbose and always use the DEBUG level.
🦋 Changeset detectedLatest commit: 920a7fd The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Coverage Report
File Coverage
|
commit: |
33feaa9
to
15da503
Compare
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 may want to introduce another env variable OPEN_NEXT_ERROR_LOG_LEVEL
to decide if we log the IgnorableError
even in debug.
All of this would be decided inside the error function
By default it would only log level 1 error and above
@@ -192,7 +193,11 @@ export default class S3Cache { | |||
} as CacheHandlerValue; | |||
} catch (e) { | |||
// We can usually ignore errors here as they are usually due to cache not being found | |||
debug("Failed to get fetch cache", e); | |||
if (isIgnorableError(e)) { |
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.
Do we want to do this here, error
should already be handling this
opennextjs-aws/packages/open-next/src/adapters/logger.ts
Lines 43 to 67 in 4a500ee
export function error(...args: any[]) { | |
// we try to catch errors from the aws-sdk client and downplay some of them | |
if ( | |
args.some((arg: AwsSdkClientCommandErrorLog) => isDownplayedErrorLog(arg)) | |
) { | |
debug(...args); | |
} else if (args.some((arg) => arg.__openNextInternal)) { | |
// In case of an internal error, we log it with the appropriate log level | |
const error = args.find( | |
(arg) => arg.__openNextInternal, | |
) as BaseOpenNextError; | |
if (error.logLevel === 0) { | |
debug(...args); | |
return; | |
} | |
if (error.logLevel === 1) { | |
warn(...args); | |
return; | |
} | |
console.error(...args); | |
return; | |
} else { | |
console.error(...args); | |
} | |
} |
Having only the
error
function deciding which error to log is probably better (and easier to read)
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.
Oh I better understand what you meant now (I didn't noticed the handling of internal errors in the logger).
Still I find having IgnorableErrors
and OPEN_NEXT_ERROR_LOG_LEVEL
a bit overkill.
Let me think more about this.
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 think IgnorableError
alone are enough in most cases, debug mode should never be used outside of when you debug so you should never see such errors in production.
The OPEN_NEXT_ERROR_LOG_LEVEL
has 1 main use imo, it's for adding the ability to mask RecoverableError
logs, but it could also be used to mask IgnorableError
in debug mode, which could be useful for us when testing something that has nothing to do with these errors
See #649 |
All "dummy" cache methods throw by design.
This PR makes the corresponding errors ignorable so that the logs are less verbose and always use the DEBUG level.