fix(extension): cdp network-capture + frame-eval robustness (3 fixes)#1984
Open
jackwener wants to merge 1 commit into
Open
fix(extension): cdp network-capture + frame-eval robustness (3 fixes)#1984jackwener wants to merge 1 commit into
jackwener wants to merge 1 commit into
Conversation
Three independent CDP-layer correctness fixes:
1. Redirect wiped the captured POST body. On an HTTP 30x, CDP re-fires
Network.requestWillBeSent with the SAME requestId (the prior hop in
`redirectResponse`) for the redirect target — usually a GET with no
postData. The handler overwrote the entry's request-body fields
unconditionally, destroying the original POST body. Now the body is
only populated on the initial send (guarded on `!redirectResponse`).
2. responseReceived created orphan entries. If readNetworkCapture()
drained the entries (clearing requestToIndex) while a request was in
flight, the later Network.responseReceived ran getOrCreate and made a
new half-entry with a defaulted method ('GET') and no request data.
Now it is lookup-only, mirroring loadingFinished.
3. evaluateInFrame had no retry on a stale cached context. A navigated/
reloaded frame invalidates its cached execution-context id, but the
executionContextDestroyed event may not be processed yet, so
Runtime.evaluate rejects with "Cannot find context with specified id".
Now that rejection drops the stale id and falls through to the
frame-target path (mirrors evaluate()'s re-resolution); genuine page
errors still propagate.
Tests: redirect-body preservation, orphan-entry prevention, and
stale-context fallback — all reverse-validated. cdp suite 15/15, tsc
clean, extension/dist rebuilt.
wearzdk
added a commit
to wearzdk/OpenCLI
that referenced
this pull request
Jun 26, 2026
…e + frame-eval robustness
wearzdk
added a commit
to wearzdk/OpenCLI
that referenced
this pull request
Jun 26, 2026
…apture across ensureAttached re-attach 冲突解决:jackwener#1984 与 jackwener#1978 各自在 cdp.test.ts 同位置追加 describe 块, 保留全部三个块(correctness / evaluateInFrame / survives-reattach)。 dist/background.js 留待 build 阶段重建。
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.
Three independent CDP-layer correctness fixes (all in
extension/src/cdp.ts), each with a reverse-validated test.1. Redirect wiped the captured POST body (data-integrity)
On an HTTP 30x, CDP re-fires
Network.requestWillBeSentwith the same requestId (the prior hop is carried inredirectResponse) for the redirect target — usually a GET with nopostData. The handler overwrote the entry's request-body fields unconditionally, destroying the original POST body. Now the body is populated only on the initial send (guarded on!redirectResponse).web networkcapturing a POST that 301/302/307-redirects (auth POSTs, URL shorteners) → read shows an empty body.2. responseReceived created orphan entries (data-integrity)
If
readNetworkCapture()drained the entries (clearingrequestToIndex) while a request was in flight, the laterNetwork.responseReceivedrangetOrCreateand produced a half-entry with a defaulted method (GET) and no request data. Now it is lookup-only, mirroringloadingFinished.web networkwhile requests are still in flight (the normal streaming pattern).3. evaluateInFrame had no retry on a stale cached context (correctness)
A navigated/reloaded frame invalidates its cached execution-context id, but the
executionContextDestroyedevent may not be processed yet, soRuntime.evaluaterejects with"Cannot find context with specified id".evaluate()has a re-resolution path;evaluateInFramedid not — it failed. Now the rejection drops the stale id and falls through to the frame-target path; genuine page-eval errors still propagate.web eval --frame Nright after the target iframe reloads (SPA dashboards).Tests
tsc --noEmitclean,extension/dist/background.jsrebuilt.Found in the bug-hunt sweep (thread #OpenCLI). Reviewer: @opus-reviewer.