When a run_playwright_code execution is resumed after timing out and the integrated browser page closes before the underlying Playwright call settles, the shared process logs an unhandled rejection for every resumed timeout.
Reproduction
- In VS Code Insiders, enable
workbench.browser.enableChatTools.
- Open Chat in Agent mode and ask the agent to open
https://example.com in the integrated browser.
- Ask the agent to call
run_playwright_code for that page with:
- code:
await page.waitForTimeout(60000); return 'done';
timeoutMs: 1000
- The tool returns a
deferredResultId. Ask the agent to call run_playwright_code again with that deferredResultId, the same page ID, no code, and timeoutMs: 1000.
- After the resumed call defers again, close the integrated browser tab before the original 60-second wait completes.
- Run Developer: Open Logs Folder and inspect
sharedprocess.log in the current session directory.
Actual behavior
The Shared Process log contains an unhandled rejection. Repeating step 4 before closing the page produces another copy for each resume:
[uncaught exception in sharedProcess]: page.evaluate: Target page, context or browser has been closed
at PlaywrightTab.runAndWaitForCompletion
at PlaywrightTab.safeRunAgainstPage
at PlaywrightSession._runAgainstPage
at async PlaywrightSession._runWithDeferral
Expected behavior
Closing the page should reject the deferred tool result when it is observed again, without reporting an unhandled rejection in the shared process.
Root cause
Each call to waitForDeferredResult creates a new DeferredPromise. After that resumed wait times out, the promise is stored for the next resume without a rejection observer. Page closure rejects both the underlying Playwright operation and each stored resume promise. The initial invocation does not have this problem because its completion-telemetry handler observes both settlement paths.
Observed in VS Code Insiders 1.134.0 on Windows.
When a
run_playwright_codeexecution is resumed after timing out and the integrated browser page closes before the underlying Playwright call settles, the shared process logs an unhandled rejection for every resumed timeout.Reproduction
workbench.browser.enableChatTools.https://example.comin the integrated browser.run_playwright_codefor that page with:await page.waitForTimeout(60000); return 'done';timeoutMs:1000deferredResultId. Ask the agent to callrun_playwright_codeagain with thatdeferredResultId, the same page ID, no code, andtimeoutMs: 1000.sharedprocess.login the current session directory.Actual behavior
The Shared Process log contains an unhandled rejection. Repeating step 4 before closing the page produces another copy for each resume:
Expected behavior
Closing the page should reject the deferred tool result when it is observed again, without reporting an unhandled rejection in the shared process.
Root cause
Each call to
waitForDeferredResultcreates a newDeferredPromise. After that resumed wait times out, the promise is stored for the next resume without a rejection observer. Page closure rejects both the underlying Playwright operation and each stored resume promise. The initial invocation does not have this problem because its completion-telemetry handler observes both settlement paths.Observed in VS Code Insiders 1.134.0 on Windows.