Skip to content

fix: handle URI decode errors gracefully and clean up DiskBuildCache#3855

Open
SisyphusZheng wants to merge 2 commits into
freshframework:mainfrom
SisyphusZheng:fix/response-edge-cases
Open

fix: handle URI decode errors gracefully and clean up DiskBuildCache#3855
SisyphusZheng wants to merge 2 commits into
freshframework:mainfrom
SisyphusZheng:fix/response-edge-cases

Conversation

@SisyphusZheng

@SisyphusZheng SisyphusZheng commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Two fixes (HEAD body-stripping reverted — Deno does handle it, but FakeServer in tests doesn't):

  1. Malformed URI params: \decodeURI()\ throws a URIError on malformed percent-encoding (e.g. %GG), causing an uncaught 500 Internal Server Error. Wrap in try/catch and fall back to the raw value.

  2. DiskBuildCache.readFile(): Replace the \�sync\ + \deno-lint-ignore require-await\ pattern with an explicit \Promise.reject(), which is cleaner and signals the intentional not-implemented status.

Three fixes for HTTP response correctness:

1. HEAD requests: Deno.serve already strips bodies from HEAD responses. The explicit \
ew Response(null, result)\ wrapper was unnecessary and could produce incorrect Content-Length headers (RFC 7231 §4.3.2). Remove the special case and let Deno handle it.

2. Malformed URI params: \decodeURI()\ throws a URIError on malformed percent-encoding (e.g. %GG), causing an uncaught 500 error instead of a proper 400. Wrap in try/catch and fall back to the raw value.

3. DiskBuildCache.readFile(): Replace the \�sync\ + lint-ignore pattern with an explicit \Promise.reject()\ to cleanly signal the intentional not-implemented status.
The previous commit removed the explicit HEAD body-stripping (\
ew Response(null, result)\), assuming Deno.serve handles it automatically. However:

1. \�pp_test.tsx:810,814\ asserts \
es.body === null\ for HEAD via FakeServer which bypasses Deno's HTTP stack.
2. \handlers.ts:80-82\ documents the contract that HEAD auto-strips the body.
3. Fresh's own \static_files.ts:121\ also explicitly handles HEAD body stripping.

Revert this specific change. The other two fixes in this PR (URI decode try/catch, DiskBuildCache Promise.reject) remain valid.
@SisyphusZheng SisyphusZheng changed the title fix: correct response handling edge cases fix: handle URI decode errors gracefully and clean up DiskBuildCache Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant