fix: handle URI decode errors gracefully and clean up DiskBuildCache#3855
Open
SisyphusZheng wants to merge 2 commits into
Open
fix: handle URI decode errors gracefully and clean up DiskBuildCache#3855SisyphusZheng wants to merge 2 commits into
SisyphusZheng wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes (HEAD body-stripping reverted — Deno does handle it, but FakeServer in tests doesn't):
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.
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.