-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Attach multiple instance of playwright to browser server #3405
Comments
Sounds like a bug, let me look into that. |
I tried to repro with playwright v1.3.0 on my mac, but everything works for me. My setup is probably different, so repro script would be very much appreciated! const playwright = require('playwright');
(async () => {
const browserServer = await playwright.chromium.launchServer({ headless: false });
const promises = Array(20).fill(0).map(async () => {
const browser = await playwright.chromium.connect({ wsEndpoint: browserServer.wsEndpoint() });
const page = await browser.newPage();
await page.goto('https://google.com.vn');
console.log('connected one more');
return browser;
});
const browsers = await Promise.all(promises);
const closedPromises = browsers.map(browser => new Promise(f => {
browser.once('disconnected', () => {
console.log('closed one more');
f();
});
}));
await Promise.all([
browserServer.close(),
...closedPromises
]);
})(); |
Here is the script to repro, run in #parent class:
#child class:
This error appears sometimes on my machine
|
Thank you for the repro! I tried reproducing this with worker_threads, but all 20 workers connect and navigate just fine, with playwright v1.3.0 and node v12.13.1. const playwright = require('playwright');
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
(async () => {
if (isMainThread) {
const browserServer = await playwright.chromium.launchServer();
const workers = [];
for (let i = 0; i < 20; i++) {
const worker = new Worker(__filename, { workerData: i });
worker.postMessage(browserServer.wsEndpoint());
workers.push(worker);
}
} else {
const messageListener = async (wsEndpoint) => {
const browser = await playwright.chromium.connect({ wsEndpoint });
const page = await browser.newPage();
await page.goto('https://google.com.vn');
console.log('connected one more ' + workerData);
}
parentPort.on('message', messageListener);
}
})(); |
can you try to run in |
Sorry, still cannot repro. Let me close this as I cannot reproduce it. Please reopen if you have a full script that does repro this. |
The story is I want to do load test with the playwright, I've tried to simulate multiple users use the playwright to run the automation.
postMessage
to each thread and send thewsEndpoint
for the child thread connect to browser server:The text was updated successfully, but these errors were encountered: