Repository navigation
fix: prune destroyed extension service workers on reload (#2978) - #3116
trukhinyuri wants to merge 1 commit into
Conversation
|
@samiyac, please review this PR (automatically distributed) |
OrKoN
left a comment
There was a problem hiding this comment.
Please check the following:
-
Fix the bug in Puppeteer (
ChromeTargetManager) sobrowser.targets()drops the old extension service worker afterbrowser.installExtension()re-installs the same extension, and emitstargetdestroyedfor it; then roll the Puppeteer version here.AGENTS.mdrequires upstream fixes first, andcreateWorkersSnapshot()onmainalready prunes againstbrowser.targets()(#2800), so a correctbrowser.targets()fixes #2978 with no change in this repository. -
Remove the
Target.getTargetsround trip and the writes to Puppeteer internals (browser._connection,browser._targetManager().getAvailableTargets().delete(...),browser.emit('targetdestroyed', ...),target._targetId) from#pruneDestroyedServiceWorkers(). The repository rules forbid@ts-expect-error,as unknown as, and Puppeteer internals outsidesrc/third_party/index.ts; mutatingTargetManagerstate from outside also races with Puppeteer's owntargetDestroyedhandling. -
Keep
createWorkersSnapshot()synchronous. Making itasyncadds a CDP round trip to everyMcpResponse.handle()that includes workers and changes the signature for every caller (#init, collectors, tests) for a workaround that request 1 makes unnecessary. -
In
tests/tools/extensions.test.ts, replace the fixedsetTimeout(…, 2000)with a poll oncontext.createWorkersSnapshot().length === 1, and put the real-browser test in a file that already launches a browser (for exampletests/McpContext.test.tsortests/tools/script.test.ts) instead of addingwithMcpContextto the mock-basedextensions.test.ts. A fixed sleep is flaky, and mock-based tool-handler test files stay browser-free. -
Rebase onto
main; the PR isDIRTY.McpContext.tschanged in #2881, #3156, #3161, and #3162 aroundcreateWorkersSnapshot()and the collector initialization.
|
@OrKoN Makes total sense, thank you! I opened upstream puppeteer/puppeteer#15614 so Once puppeteer/puppeteer#15614 lands and Puppeteer rolls here, I will rebase this PR onto |
|
Closing this PR for now until the next Puppeteer release rolls into this repository with the upstream fix from puppeteer/puppeteer. I will reopen with the integration test once the roll lands. |
Fixes #2978
Summary
Target.getTargetsfrom the browser CDP session insrc/McpContext.tsto prune destroyed extension service worker targets that do not emit target destruction events on reload.tests/tools/extensions.test.ts,tests/tools/script.test.ts, andtests/tools/console.test.ts.