Skip to content

Commit cf09cfa

Browse files
Add additional error messaging for errors from KV (#7989)
1 parent 46a16bc commit cf09cfa

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/cuddly-bees-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/workers-shared": patch
3+
---
4+
5+
Adds additional error messaging for errors from KV.

packages/workers-shared/asset-worker/src/utils/kv.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ export async function getAssetWithMetadataFromKV(
4343
return asset;
4444
} catch (err) {
4545
if (attempts >= retries) {
46-
throw new Error(
47-
`Requested asset ${assetKey} could not be fetched from KV namespace.`
48-
);
46+
let message = `Requested asset ${assetKey} could not be fetched from KV namespace.`;
47+
if (err instanceof Error) {
48+
message = `Requested asset ${assetKey} could not be fetched from KV namespace: ${err.message}`;
49+
}
50+
throw new Error(message);
4951
}
5052

5153
// Exponential backoff, 1 second first time, then 2 second, then 4 second etc.

0 commit comments

Comments
 (0)