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(cache): log cache errors as trace #10449

Merged
merged 2 commits into from
Jun 17, 2021
Merged

Conversation

JamieMagee
Copy link
Contributor

Changes:

Log errors caught by the cache decorator as trace.

This matches what's done further up the stack in datasource/index.ts: [1], [2]. The error will eventually bubble up to logError, where selective details from it are logged at the debug level, instead of the entire error:

function logError(datasource, lookupName, err): void {
const { statusCode, code: errCode, url } = err;
if (statusCode === 404) {
logger.debug({ datasource, lookupName, url }, 'Datasource 404');
} else if (statusCode === 401 || statusCode === 403) {
logger.debug({ datasource, lookupName, url }, 'Datasource unauthorized');
} else if (errCode) {
logger.debug(
{ datasource, lookupName, url, errCode },
'Datasource connection error'
);
} else {
logger.debug({ datasource, lookupName, err }, 'Datasource unknown error');
}
}

While I could split this into 3 different try/catch blocks (for the cache get, the method call, and the cache set) I think these parts are less likely to throw an error.

Context:

Fixed #10445

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@JamieMagee JamieMagee force-pushed the fix/cache-decorator-error-handling branch from c901cd4 to cfbabde Compare June 17, 2021 03:40
viceice
viceice previously approved these changes Jun 17, 2021
@JamieMagee JamieMagee force-pushed the fix/cache-decorator-error-handling branch from cfbabde to b45926a Compare June 17, 2021 04:03
@JamieMagee JamieMagee force-pushed the fix/cache-decorator-error-handling branch from b45926a to 2f3ebac Compare June 17, 2021 04:05
@viceice viceice merged commit 55d23ad into main Jun 17, 2021
@viceice viceice deleted the fix/cache-decorator-error-handling branch June 17, 2021 05:36
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 25.44.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache decorator noisily logs lookup errors
3 participants