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): write swr and update errors to console #1794

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/runtime/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export function defineCachedFunction<T, ArgsT extends unknown[] = unknown[]>(
const promise = useStorage()
.setItem(cacheKey, entry)
.catch((error) => {
console.error(`[nitro] [cache] Cache write error.`, error);
useNitroApp().captureError(error, { event, tags: ["cache"] });
});
if (event && event.waitUntil) {
Expand All @@ -132,11 +133,10 @@ export function defineCachedFunction<T, ArgsT extends unknown[] = unknown[]>(
}

if (opts.swr && entry.value) {
// eslint-disable-next-line no-console
_resolvePromise.catch((error) => {
console.error(`[nitro] [cache] SWR handler error.`, error);
useNitroApp().captureError(error, { event, tags: ["cache"] });
});
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
return entry;
}

Expand Down