adapter-cloudflare-workers: Throws KVError if asked for a nonexisting asset #9288
Labels
low hanging fruit
pkg:adapter-cloudflare-workers
ready to implement
please submit PRs for these issues!
Milestone
Describe the bug
It seems when deployed to Cloudflare Workers, requests for non-existing assets get a 500 internal error, not a 404.
The page says "Error 1101 Worker threw exception".
wrangler tail
shows(the "REDACTED" is literal, not my editing; see below)
I've observed this two ways:
_app/immutable/assets/GoogleAnalytics.HASH.css
to_app/immutable/assets/REDACTED.css
What seems to be happening is that
@sveltejs/adapter-cloudflare-workers
functionget_asset_from_kv
callsgetAssetFromKV
from@cloudflare/kv-asset-handler
without catching exceptions, and that function is documented to throwKVError
on not found.It seems like it should catch
KVError
andthrow error(404, {...})
in its place.https://github.com/cloudflare/kv-asset-handler#getassetfromkv
kit/packages/adapter-cloudflare-workers/files/entry.js
Line 88 in 2d8c63a
Reproduction
https://github.com/tv42/sveltekit-issue9288-cloudflare-adapter-404
Logs
GET https://example.com/blah/_app/immutable/assets/REDACTED.css - Exception Thrown @ 3/2/2023, 1:15:01 PM ✘ [ERROR] Error: KVError: could not find blah/_app/immutable/assets/REDACTED.css in your content namespace
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: