Add: window.__abs_dumpTrace bridge for CDP debug-trace retrieval#223
Conversation
Exposes window.__abs_dumpTrace() in the top frame's MAIN world whenever the debug-trace recorder is on (build-flag default or popup toggle) so CDP-driven harnesses can scrape the per-tab mutation record via Runtime.evaluate to investigate false positives without a human flipping the popup toggle. Centralizes the recipe in a new debug-trace docs page; install.md and the four CDP integration docs link out instead of duplicating. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
1 issue found.
About Unblocked
Unblocked has been set up to automatically review your team's pull requests to identify genuine bugs and issues.
📖 Documentation — Learn more in our docs.
💬 Ask questions — Mention @unblocked to request a review or summary, or ask follow-up questions.
👍 Give feedback — React to comments with 👍 or 👎 to help us improve.
⚙️ Customize — Adjust settings in your preferences.
| postResponse(id, { error: String(error) }); | ||
| return; | ||
| } | ||
| postResponse(id, { entries: response.entries }); |
There was a problem hiding this comment.
chrome.runtime.sendMessage resolves with undefined when the background listener returns undefined without calling sendResponse — which happens here when the get-tab-debug-trace handler has no valid tabId (line 442-444 of background.ts). In that case response is undefined and response.entries throws TypeError: Cannot read properties of undefined (reading 'entries').
The popup's own sendMessage call in use-tab-detections.ts correctly types the response as … | undefined and uses response?.entries ?? []. This code should do the same:
| postResponse(id, { entries: response.entries }); | |
| postResponse(id, { entries: response?.entries ?? [] }); |
There was a problem hiding this comment.
Fixed in 7ec3e85 — widened the variable to GetTabDebugTraceResponse | undefined and switched to response?.entries ?? [], mirroring the popup's use-tab-detections.ts pattern. Added a regression test in dump-trace-content-bridge.test.ts that mocks sendMessage to resolve with undefined (the missing-tabId case) and asserts an empty-entries response goes back to the page instead of a TypeError. Good catch — this would have hit any off-tab caller in production. — Claude Code, on behalf of @twschiller
The biome auto-fix rewrote `window` → `globalThis` for the same-window comparison, but TypeScript's `typeof globalThis` doesn't structurally satisfy `MessageEventSource`. Hold a `Window`-typed alias once and use it for the comparison and postMessage origin so both biome and tsc are happy. Add the dump-trace bundle entrypoint to knip's allow-list alongside the other probe entrypoints. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
When sender.tab?.id is missing the background's get-tab-debug-trace handler returns undefined without calling sendResponse, so chrome.runtime.sendMessage resolves with undefined and the previous response.entries dereference crashed with TypeError. Widen the type to GetTabDebugTraceResponse | undefined and fall back to an empty entries array. Add a regression test covering the undefined-reply path. Caught by Unblocked review on PR #223. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
window.__abs_dumpTrace()in the top frame's MAIN world whenever the debug-trace recorder is on — either thedebugTrace: truebuild flag (CDP-driven harnesses like Browserbase/Hermes/browser-use/OpenClaw) or the popup toggle (Chrome Web Store installs). CDP clients call it viaRuntime.evaluate("(async () => await window.__abs_dumpTrace())()", { awaitPromise: true })to scrape the per-tab mutation record mid-run without needing the popup's Export button.dump-trace-bridge-source.ts) ↔ isolated content-script bridge (dump-trace-content-bridge.ts) ↔ background (get-tab-debug-tracemessage) ↔ IDB (getEventsForTab). Registered/unregistered bydump-trace-bridge-registration.tson everydebugTraceStoragechange so flipping the popup toggle reaches the next navigation./debug-trace/docs page (single source of truth).install.mdplus the four CDP integration docs (browserbase-python.md,hermes-agent.md,browser-use.md,openclaw.md) get short "Investigating a false positive" pointers instead of duplicating the recipe.Test plan
bun run check(biome + eslint) — cleanbun run test— 1905/1905 pass; 20 new tests acrossdump-trace-bridge-registration.test.ts,dump-trace-content-bridge.test.ts,dump-trace-bridge-source.test.tsbun run build— extension bundles cleanly with the newdump-trace-bridge.jsentrypre-commit runon the touched docs — mdformat + markdownlint passastro build— 9 pages built, new/debug-trace/route resolvesdebugTrace: truedefaults; confirmtypeof window.__abs_dumpTrace === "function"and thatawait window.__abs_dumpTrace()returns entries matching the popup ExportdebugTrace; confirmwindow.__abs_dumpTraceis undefined; flip popup toggle, reload, confirm it appears; flip off, reload, confirm it's goneRuntime.evaluaterecipe from the docs returns entries🤖 Generated with Claude Code