You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
failed: [rebrowser-patches] acquireContextId failed on chrome extensions pages #59
Hi!
I tried to use rebrowser-puppeteer on the chrome extension page (Metamask in the example) and when I try to get any element, I get an error:
Error: Waiting for selector `body` failed: [rebrowser-patches] acquireContextId failed
at ExecutionContext.acquireContextId (/home/user/Desktop/qwe/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/ExecutionContext.js:470:23)
at async IsolatedWorld.adoptBackendNode (/home/user/Desktop/qwe/node_modules/puppeteer-core/src/cdp/IsolatedWorld.ts:229:3)
at async IsolatedWorld.transferHandle (/home/user/Desktop/qwe/node_modules/puppeteer-core/src/cdp/IsolatedWorld.ts:65:1)
at async Function.waitFor (/home/user/Desktop/qwe/node_modules/puppeteer-core/src/common/QueryHandler.ts:204:14)
at async CdpFrame.waitForSelector (/home/user/Desktop/qwe/node_modules/puppeteer-core/src/api/Frame.ts:729:13)
at async CdpPage.waitForSelector (/home/user/Desktop/qwe/node_modules/puppeteer-core/src/api/Page.ts:2942:12)
change to REBROWSER_PATCHES_RUNTIME_FIX_MODE=alwaysIsolated, the meta mask can be loaded, but the page.exposeFunction and page.on("console",..) are all invalid
Found the cause. MetaMask's pages use LavaMoat "scuttling", which makes reading the global self throw, and the patch's context handshake called self[...]. We reproduced it with MetaMask 13.52 on 25.14.0. With #132, the patch finds the page's context without running anything in the page (and its fallback uses window, which pages can't redefine). With it, waitForSelector() and evaluate() on MetaMask's home.html work in the default mode, the same as with stock Puppeteer. There's a regression test for it, and it ships in the next release. I'll close this then.
Released in v1.1.1: rebrowser-puppeteer-core / rebrowser-puppeteer25.14.100, rebrowser-playwright-core / rebrowser-playwright1.64.100, and rebrowser-playwright1.64.100 on PyPI. (npm doesn't allow re-publishing 25.14.0 / 1.64.1, so this fix release uses .100.) Extension pages such as MetaMask's home.html now work in the default mode. Closing.
Activity
nwebson commentedon Nov 3, 2024
Please run it with
REBROWSER_PATCHES_DEBUG=1and show the full log here. That would be very helpful.n0m44 commentedon Nov 3, 2024
@nwebson ty for answer
log:
fred8617 commentedon Jan 26, 2025
same issue here, any solution? thanks
fred8617 commentedon Jan 29, 2025
change to
REBROWSER_PATCHES_RUNTIME_FIX_MODE=alwaysIsolated, the meta mask can be loaded, but thepage.exposeFunctionandpage.on("console",..)are all invalidrebrowsernet commentedon Oct 18, 2026
Found the cause. MetaMask's pages use LavaMoat "scuttling", which makes reading the global
selfthrow, and the patch's context handshake calledself[...]. We reproduced it with MetaMask 13.52 on 25.14.0. With #132, the patch finds the page's context without running anything in the page (and its fallback useswindow, which pages can't redefine). With it,waitForSelector()andevaluate()on MetaMask'shome.htmlwork in the default mode, the same as with stock Puppeteer. There's a regression test for it, and it ships in the next release. I'll close this then.rebrowsernet commentedon Oct 18, 2026
Released in v1.1.1:
rebrowser-puppeteer-core/rebrowser-puppeteer25.14.100,rebrowser-playwright-core/rebrowser-playwright1.64.100, andrebrowser-playwright1.64.100 on PyPI. (npm doesn't allow re-publishing 25.14.0 / 1.64.1, so this fix release uses.100.) Extension pages such as MetaMask'shome.htmlnow work in the default mode. Closing.