Skip to content

Commit

Permalink
Fix `Error: Failed to add page binding with name ___pepr_cs: window['…
Browse files Browse the repository at this point in the history
…___pepr_cs'] already exists!`

When page.solveRecaptchas() is called multiple times, an error is thrown

```
Error: Failed to add page binding with name ___pepr_cs: window['___pepr_cs'] already exists!
```

In my test I use puppeteer@14.4.1 with its default Chrome, puppeteer-extra@3.3.4 and puppeteer-extra-plugin-recaptcha@3.6.8. I haven't tried other versions.
  • Loading branch information
codynguyen authored Apr 17, 2024
1 parent 39248f1 commit 99f5c71
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/puppeteer-extra-plugin-recaptcha/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ export class PuppeteerExtraPluginRecaptcha extends PuppeteerExtraPlugin {

if (this.contentScriptDebug.enabled) {
if ('exposeFunction' in page) {
await page.exposeFunction(this.debugBindingName, onDebugBindingCalled)
try {
await page.exposeFunction(this.debugBindingName, onDebugBindingCalled);
} catch (err) {
this.debug('`debugBindingName` function is already exposed');
}
}
}
// Even without a recaptcha script tag we're trying, just in case.
Expand Down

0 comments on commit 99f5c71

Please sign in to comment.