Repository navigation
Fail, don't crash, when an expected request never reaches the origin - #221
Merged
Merged
Conversation
…origin
checkServerRequests reads serverRequest.request_headers for
expected_request_headers and expected_request_headers_missing without checking
that the origin saw the request. If the cache answers it from its own store,
serverState has no entry and the check throws a TypeError ("Cannot read
properties of undefined (reading 'request_headers')") instead of reporting a
result.
conditional-etag-vary-headers-mismatch hits this with a cache that ignores
Vary: request 2 is served from cache, so the origin never sees it. Assert that
the request was sent, as the validating-header path already does. Both cases
fail, since expecting a header to be absent still implies a request was made.
Checked against a URL-keyed proxy that ignores Vary: the test now reports
"request 2 wasn't sent to server" rather than the TypeError.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
A run against a cache that ignores
Varyreportedconditional-etag-vary-headers-mismatchas aTypeError("Cannot read properties of undefined (reading 'request_headers')") rather than a result.In
checkServerRequests, theexpected_request_headersandexpected_request_headers_missingblocks readserverRequest.request_headerswithout checking that the origin saw the request. When the cache answers request 2 from its store, there's no server-side record for it, so the read throws. Only the validating-header path had a guard.The fix asserts that the request was sent before checking its headers, in both blocks.
expected_request_headers_missingfails too, because expecting a header to be absent still implies the request was made.I considered the
not_cachedbranch, which also dereferencesserverRequest, and left it alone: the response-level check at the top of the same function rejects a cached response first, so that line isn't reached in practice.Verified against a small proxy that caches by URL and ignores
Vary.conditional-etag-vary-headers-mismatchnow reportsrequest 2 wasn't sent to server; before the change it threw theTypeError.npm run lintandnpm testpass. I didn't run the full suite or regenerate any results.AI-generated (Claude Code), from a session where Mark reported the failure, agreed the semantics for the
_missingcase, and reviewed the diagnosis. He hasn't reviewed this PR text.🤖 Generated with Claude Code