Skip to content

Commit 25f82cc

Browse files
committed
fix: wrap r2 get call with try catch
1 parent dbb6ec9 commit 25f82cc

File tree

1 file changed

+7
-5
lines changed
  • packages/api/src/perma-cache

1 file changed

+7
-5
lines changed

packages/api/src/perma-cache/get.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ export async function permaCacheGet(request, env) {
1919
const normalizedUrl = getNormalizedUrl(sourceUrl, env)
2020
const r2Key = normalizedUrl.toString()
2121

22-
const r2Object = await env.SUPERHOT.get(r2Key)
23-
if (r2Object) {
24-
return new Response(r2Object.body)
22+
try {
23+
const r2Object = await env.SUPERHOT.get(r2Key)
24+
if (r2Object) {
25+
return new Response(r2Object.body)
26+
}
27+
} catch (_) {
28+
throw new UrlNotFoundError()
2529
}
26-
27-
throw new UrlNotFoundError()
2830
}

0 commit comments

Comments
 (0)