← Back to Discord Forum

Cannot launch new browser when one already initialized

I have the next fixture:

async function configPage<T extends IPages>(pageClass: new (args: Page) => T, fn: (page: T) => Promise<void>) {
  const browser = await chromium.launch();
  const fileName = './appLoginInfo.json';
  fs.writeFileSync(fileName, APP_LOGIN_INFO as string, 'utf-8');
  const context = await browser.newContext({ storageState: fileName });
  await context.route(/(analytics|fonts)/, (route) => route.abort());
  const page = new pageClass(await context.newPage());

  await fn(page);

  await browser.close();

and through the test I'm initialize new browser with new context and page like this:

static async initializeNewContextWithPage<IPages>(type: new (obj: Page) => IPages): Promise<IPages> {
    const browser = await chromium.launch();
    const context = await browser.newContext();
    await context.route(/(analytics|fonts)/, (route) => route.abort());
    const page = await context.newPage();
    return new type(page);

when it's ran on the launching new browser 2nd time the timeout exception is thrown.

Error: browserType.launch: Timeout 180000ms exceeded

Any ideas? Before updating to the latest version it's worked

This thread is trying to answer question "Why does launching a new browser when one is already initialized result in a timeout exception, and how can this issue be resolved?"

18 replies

Does it work with an increased timeout


Did you resintall the browsers for playwright ?

$ npx playwright uninstall --all # remove all ever-install Playwright browsers

Then reinstall them?

just tried. Did not help

Is the issue with all browser types?

I didnot check it for other, I do not need it

No but it will tell you if it’s an issue specific to chromium

ok, let me try

same for firefox and webkit

I think this is a bug

I created a bug report for this

Last thing i can think of trying.

Reinstall Playwright: If you haven’t done so already, try reinstalling Playwright and the associated browser binaries all together. Remove the node_modules folder and any lock files, then reinstall the dependencies.

let's try, do you think some cache?

nope, it's not helped

I’m out of ideas sorry

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.