-
Notifications
You must be signed in to change notification settings - Fork 52
feat(cache): stale-on-error via LRU touch on bgFlights failure #1132
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -337,7 +337,14 @@ const wrapLoader = ( | |
| stats.cache.add(1, { status, loader }); | ||
|
|
||
| bgFlights.do(request.url, callHandlerAndCache) | ||
| .catch((error) => logger.error(`loader error ${error}`)); | ||
| .catch((error) => { | ||
| logger.error(`loader error ${error}`); | ||
| // Origin failed — extend LRU TTL so stale content keeps being served | ||
| // while origin recovers, instead of evicting and returning a hard error. | ||
| (cache as Cache & { touch?: (r: RequestInfo | URL) => Promise<void> }) | ||
| .touch?.(request) | ||
| .catch((e) => logger.error(`loader touch error ${e}`)); | ||
| }); | ||
|
Comment on lines
+340
to
+347
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting to pass CI. The pipeline reports 🤖 Prompt for AI AgentsTypeError when If the cache implementation doesn't have a 🐛 Proposed fix: extend optional chaining to the catch call (cache as Cache & { touch?: (r: RequestInfo | URL) => Promise<void> })
.touch?.(request)
- .catch((e) => logger.error(`loader touch error ${e}`));
+ ?.catch((e) => logger.error(`loader touch error ${e}`));🤖 Prompt for AI Agents |
||
| } else { | ||
| status = "hit"; | ||
| stats.cache.add(1, { status, loader }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
P1: The optional
touchcall is followed by a non-optional.catch, which can throw whentouchis not implemented.Prompt for AI agents