Stop a body-less response from killing the whole sitespeed run - #1610
Merged
Merged
Conversation
chrome-custom.cjs enables CDP Fetch interception on Documents and then called Fetch.getResponseBody unconditionally. When the response has no retrievable body the call rejects with "Can only get response body on requests captured after headers received". The listener is async, so that rejection is unhandled, and under Node 24 an unhandled rejection terminates the process - which is the sitespeed process. One awkward response therefore lost the entire test run, not just that request. Reproducer: any URL answering 401 with content-length 0, for example an Azure App Service behind Entra auth. Test 15 died after ~7 seconds and scored -1. Fixes: - Release requests paused before a response exists (network error, or no responseStatusCode); getResponseBody cannot succeed for those. - Guard getResponseBody and fulfillRequest, releasing the request instead of leaking a rejection. - Scope bodyResult with let. It was an implicit global assigned across an await, so concurrent Document interceptions could read each other's body. Fetch.continueRequest is used to release in both stages; verified against Chromium 150 that it resolves a Response-stage pause (8/8). A pause that is never released would stall the page load, so the failure is logged rather than swallowed. Verified: the 401 site now completes and scores instead of crashing. On a healthy site the new branches never execute and the rating is unchanged (4.49 vs 4.47, run-to-run variance). With a sitespeed-rules.json present, header and HTML rewriting still applies identically (2 header injections, 2 HTML rewrites, 0 crashes, before and after). Co-Authored-By: Claude Opus 5 (1M context) <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.
chrome-custom.cjs enables CDP Fetch interception on Documents and then called Fetch.getResponseBody unconditionally. When the response has no retrievable body the call rejects with "Can only get response body on requests captured after headers received". The listener is async, so that rejection is unhandled, and under Node 24 an unhandled rejection terminates the process - which is the sitespeed process. One awkward response therefore lost the entire test run, not just that request.
Reproducer: any URL answering 401 with content-length 0, for example an Azure App Service behind Entra auth. Test 15 died after ~7 seconds and scored -1.
Fixes:
Fetch.continueRequest is used to release in both stages; verified against Chromium 150 that it resolves a Response-stage pause (8/8). A pause that is never released would stall the page load, so the failure is logged rather than swallowed.
Verified: the 401 site now completes and scores instead of crashing. On a healthy site the new branches never execute and the rating is unchanged (4.49 vs 4.47, run-to-run variance). With a sitespeed-rules.json present, header and HTML rewriting still applies identically (2 header injections, 2 HTML rewrites, 0 crashes, before and after).