Open
Description
Rebrowser version: 1.49.1
Library patched: Playwright
Environment: Ubuntu 22.04
Node version: v20.17.0
REBROWSER_PATCHES_RUNTIME_FIX_MODE: not explicitly set, using default value
Dependencies:
"playwright": "npm:rebrowser-playwright@^1.49.1",
"playwright-core": "npm:rebrowser-playwright-core@^1.49.1",
Additional info: Running code on virtual display (Xvfb) in non-headless mode
Steps to reproduce
- Set up virtual display
Xvfb :1 -screen 0 1920x1080x24+32 -fbdir /var/tmp
- Run the code with:
DISPLAY=:1 node index.js
Code:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({
headless: false,
args: ['--disable-blink-features=AutomationControlled'],
});
const page = await browser.newPage();
await page.goto('https://showmyip.com/', { waitUntil: 'domcontentloaded' });
// can be any script that takes time to evaluate
const result = await page.evaluate(`
new Promise(resolve => { setTimeout(() => resolve('test'), 5000) })
`);
console.log(result);
await page.close();
await browser.close();
})();
Script crashes with an exception:
node:internal/process/promises:391
triggerUncaughtException(err, true /* fromPromise */);
^
page.evaluate: Execution context was destroyed, most likely because of a navigation
at /home/dmitry/projects/personal/testing-captcha/playwright/error.js:11:31 {
name: 'Error'
}
Executing the same code with plain (unpatched) Playwright library works as expected: "test" is logged into the console.
There is another error which is related (in my opinion).
Code:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({
headless: false,
args: ['--disable-blink-features=AutomationControlled'],
});
const page = await browser.newPage();
// Use any script content
await page.addInitScript({ content: 'const x = "Hi there";' });
await page.goto('https://showmyip.com/', { waitUntil: 'domcontentloaded' });
// Just wait a couple of seconds without closing page/browser
})();
Error is thrown:
[rebrowser-patches][frames._context] cannot get world, error: ProtocolError: Protocol error (Page.createIsolatedWorld): Internal server error, session closed.
at /home/dmitry/projects/personal/testing-captcha/playwright/node_modules/playwright-core/lib/server/chromium/crConnection.js:135:16
at new Promise (<anonymous>)
at CRSession.send (/home/dmitry/projects/personal/testing-captcha/playwright/node_modules/playwright-core/lib/server/chromium/crConnection.js:131:12)
at CRSession.__re__getMainWorld (/home/dmitry/projects/personal/testing-captcha/playwright/node_modules/playwright-core/lib/server/chromium/crConnection.js:308:54)
at runNextTicks (node:internal/process/task_queues:60:5)
at process.processImmediate (node:internal/timers:454:9)
at process.callbackTrampoline (node:internal/async_hooks:130:17)
at async CRSession.__re__emitExecutionContext (/home/dmitry/projects/personal/testing-captcha/playwright/node_modules/playwright-core/lib/server/chromium/crConnection.js:246:28)
at async Frame.evaluateExpression (/home/dmitry/projects/personal/testing-captcha/playwright/node_modules/playwright-core/lib/server/frames.js:628:21) {
type: 'closed',
method: 'Page.createIsolatedWorld',
logs: undefined
}
This error is not thrown if executed with REBROWSER_PATCHES_RUNTIME_FIX_MODE=0
Metadata
Metadata
Assignees
Labels
No labels