Skip to content

Commit c7149b9

Browse files
committed
playwright patches fixes
1 parent b924db3 commit c7149b9

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rebrowser-patches",
3-
"version": "1.0.10",
3+
"version": "1.0.12",
44
"description": "Collection of patches for puppeteer and playwright to avoid automation detection and leaks. Helps to avoid Cloudflare and DataDome CAPTCHA pages. Easy to patch/unpatch, can be enabled/disabled on demand.",
55
"keywords": [
66
"automation",

patches/playwright-core/1.47.x-lib.patch

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@
8484
}
8585
setPendingDocument(documentInfo) {
8686
this._pendingDocument = documentInfo;
87-
@@ -582,6 +585,34 @@
87+
@@ -582,6 +585,39 @@
8888
return this._page._delegate.getFrameElement(this);
8989
}
9090
_context(world) {
9191
+ if (process.env['REBROWSER_PATCHES_RUNTIME_FIX_MODE'] !== '0') {
9292
+ // rebrowser-patches: use only utility context, create it on demand and cache
9393
+ if (this._isolatedContext !== undefined) {
94-
+ return this._isolatedContext;
94+
+ return Promise.resolve(this._isolatedContext);
9595
+ }
9696
+ const utilityWorldName = process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] !== '0' ? process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] || 'util' : '__playwright_utility_world__';
9797
+ return this._page._delegate._mainFrameSession._client.send('Page.createIsolatedWorld', {
@@ -111,9 +111,14 @@
111111
+ this._isolatedContext = new dom.FrameExecutionContext(delegate, this, 'utility');
112112
+ return this._isolatedContext;
113113
+ }).catch(error => {
114-
+ // probably target is closed
114+
+ if (error.message.includes('No frame for given id found')) {
115+
+ // ignore, frame is already gone
116+
+ return {
117+
+ destroyedReason: 'Frame was detached'
118+
+ };
119+
+ }
115120
+ _debugLogger.debugLogger.log('error', error);
116-
+ console.error('[rebrowser-patches][frames._context] cannot create utility world');
121+
+ console.error('[rebrowser-patches][frames._context] cannot create utility world, error:', error);
117122
+ });
118123
+ }
119124
return this._contextData.get(world).contextPromise.then(contextOrDestroyedReason => {

patches/playwright-core/1.47.x-src.patch

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@
8484
}
8585

8686
setPendingDocument(documentInfo: DocumentInfo | undefined) {
87-
@@ -735,6 +738,38 @@
87+
@@ -735,6 +738,43 @@
8888
}
8989

9090
_context(world: types.World): Promise<dom.FrameExecutionContext> {
9191
+ if (process.env['REBROWSER_PATCHES_RUNTIME_FIX_MODE'] !== '0') {
9292
+ // rebrowser-patches: use only utility context, create it on demand and cache
9393
+ if (this._isolatedContext !== undefined) {
94-
+ return this._isolatedContext
94+
+ return Promise.resolve(this._isolatedContext)
9595
+ }
9696
+
9797
+ const utilityWorldName = process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] !== '0' ? (process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] || 'util') : '__playwright_utility_world__';
@@ -114,9 +114,14 @@
114114
+ return this._isolatedContext
115115
+ })
116116
+ .catch(error => {
117-
+ // probably target is closed
117+
+ if (error.message.includes('No frame for given id found')) {
118+
+ // ignore, frame is already gone
119+
+ return {
120+
+ destroyedReason: 'Frame was detached'
121+
+ }
122+
+ }
118123
+ debugLogger.log('error', error)
119-
+ console.error('[rebrowser-patches][frames._context] cannot create utility world')
124+
+ console.error('[rebrowser-patches][frames._context] cannot create utility world, error:', error)
120125
+ })
121126
+ }
122127
+

0 commit comments

Comments
 (0)