Skip to content

fix(har): do not hang when response extra info never arrives - #42450

Closed
Ashraf Ali (ashrafiucse) wants to merge 3 commits into
microsoft:mainfrom
ashrafiucse:fix-42448
Closed

fix(har): do not hang when response extra info never arrives#42450
Ashraf Ali (ashrafiucse) wants to merge 3 commits into
microsoft:mainfrom
ashrafiucse:fix-42448

Conversation

@ashrafiucse

@ashrafiucse Ashraf Ali (ashrafiucse) commented Aug 28, 2026

Copy link
Copy Markdown

Summary

  • When the HAR recording stops, drop the pending data-upgrade barriers (raw headers, sizes, compression) instead of waiting for the network extra info that may never arrive — provisional values are already recorded as a fallback for exactly this case
  • The extra info promises are not force-resolved on the server side, since responseReceivedExtraInfo can still arrive after loadingFinished
  • Two regression tests in har.spec.ts that withhold Network.responseReceivedExtraInfo / Network.loadingFinished for a single request via a CDP websocket proxy (both hang without the fix)

Fixes #42448

Chromium may advertise `hasExtraInfo` on a response and then never deliver
the extra info, or stop reporting the request at all after responseReceived.
Two changes make this survivable:

- when the request finishes without extra info for some of its responses,
  resolve their raw header promises with the provisional headers, in the
  same way as for responses without the extra info flag;
- when the HAR recording stops, drop the pending raw header upgrade barriers
  instead of waiting for them - provisional headers are already recorded
  as a fallback for exactly this case.

Fixes: microsoft#42448
@ashrafiucse

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

}

// We are not done yet.
// The request is over, so no more extra info can arrive for it. Fall back to

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not necessarily true as responseReceivedExtraInfo can come later so please undo this change

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undone in 2148b48 — nothing is force-resolved on the server side anymore.

The hang is now fixed entirely on the tracer side (70ff634): when the recording stops, HarTracer.flush() drops the still-pending barriers that only upgrade already-recorded provisional data (raw headers, sizes, compression). This is still needed because BrowserContext.close() flushes the HAR before the pages are closed, so those barriers would otherwise wait for the extra info forever, e.g. when loadingFinished arrives without responseReceivedExtraInfo.

Verified with the repro from the issue in all three modes (extra info withheld / loadingFinished withheld / both) — context.close() completes in each.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

2 failed
❌ [msedge] › mcp/annotate.spec.ts:316 › should annotate via direct browser_annotate MCP call @mcp-windows-latest-msedge
❌ [msedge] › mcp/annotate.spec.ts:349 › should annotate when context has no fixed viewport @mcp-windows-latest-msedge

8257 passed, 1361 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

7 flaky ⚠️ [chromium-library] › library/browsercontext-page-event.spec.ts:173 › should work with Ctrl-clicking `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:699 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:664 › screencast › should capture full viewport `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-library] › library/video.spec.ts:664 › screencast › should capture full viewport `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node20`
⚠️ [chromium-library] › library/browsertype-connect.spec.ts:984 › run-server › socks proxy › should proxy requests from fetch api over ipv6 `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`

51258 passed, 1244 skipped


Merge workflow run.

Revert the eager resolution of pending responses with provisional
headers when a request finishes: responseReceivedExtraInfo can still
arrive after loadingFinished. The HarTracer flush() change alone is
enough to avoid hanging, as provisional headers are recorded as a
fallback.

Fixes: microsoft#42450 (review)
With the response extra info never arriving, the request can still
finish normally (Network.loadingFinished is delivered). The HAR tracer
then adds sizes and compression calculation barriers that await the
extra-info-fed response headers size promise, which never resolves.
Since tracing flush runs before the pages are closed, these barriers
hang context.close() the same way the raw header barriers did.

Treat all barriers that only upgrade already-recorded provisional data
as droppable on flush, not just the raw header ones. The extra info is
not force-resolved server side because it can still arrive after
loadingFinished.

Fixes: microsoft#42448
@dgozman

Copy link
Copy Markdown
Collaborator

Let's start with figuring out the problem and usecase first. We can reopen this PR once the issue is clear.

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.

[Bug]: recordHar: context.close() hangs when a response's raw headers never arrive

3 participants