Skip to content
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]: Hang when closing a lot of headed net::ERR_CONNECTION_REFUSED windows #8838

Closed
stevenwdv opened this issue Aug 24, 2022 · 8 comments
Closed

Comments

@stevenwdv
Copy link

stevenwdv commented Aug 24, 2022

Bug description

Puppeteer sometimes fails to close some net::ERR_CONNECTION_REFUSED windows when closing the main page of each incognito context on a headed browser.

Steps to reproduce the problem:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({headless: false});

const total = 30;
let closed  = 0;
const ctxs  = await Promise.all(Array(total).fill(null).map(async () => {
	const ctx  = await browser.createIncognitoBrowserContext();
	const page = await ctx.newPage();
	try {
		// IMPORTANT: localhost:9876 does NOT actually host a server
		await page.goto('https://localhost:9876/', {waitUntil: 'load'});
	} catch {/*intentionally ignore*/}
	await page.close();
	console.log(`closed ${++closed}/${total}`);
	return ctx;
}));
console.log('all pages closed');
await browser.close();
console.log('all done');

Which will often fail to close one or more windows and hang indefinitely and output something like:

closed 1/30
closed 2/30
closed 3/30
closed 4/30
closed 5/30
closed 6/30
closed 7/30
closed 8/30
closed 9/30
closed 10/30
closed 11/30
closed 12/30
closed 13/30
closed 14/30
closed 15/30
closed 16/30
closed 17/30
closed 18/30
closed 19/30
closed 20/30
closed 21/30
closed 22/30
closed 23/30
closed 24/30
closed 25/30
closed 26/30
closed 27/30
closed 28/30

(You might need to run it a couple of times or increase total and increase the timeout in DeferredPromise.)

This happens both with the bundled Chromium v105.0.5173.0 and with the same puppeteer version but Chrome v104.0.5112.102.

May be related to #8691, but that issue does not seem to occur with Chrome v104.0.5112.102.

Puppeteer version

16.2.0 19.3.0

Node.js version

18.7.0

npm version

8.17.0

What operating system are you seeing the problem on?

Windows

Relevant log output

No response

@stevenwdv
Copy link
Author

Probably related is that sometimes while closing a lot of windows Node.js exits the process because it found that some Promise could never be resolved.

@jrandolf
Copy link
Contributor

This strikes me as an issue of having too many processes resulting in some kind of resource problem. Do you know if this occurs always with, say, 100 processes?

@stevenwdv
Copy link
Author

@jrandolf You mean total = 100 but now with an existing URL?

@jrandolf
Copy link
Contributor

Yes.

@stevenwdv
Copy link
Author

@jrandolf You mean total = 100 but now with an existing URL?

I tried this, and the problem doesn't occur, only with an invalid URL (or e.g. https on 8080 when the server only does http).

@stevenwdv
Copy link
Author

FYI: still happens with puppeteer 18.0.3

@stevenwdv
Copy link
Author

Chromium update to M107 did not fix this unfortunately

@OrKoN
Copy link
Collaborator

OrKoN commented Mar 29, 2024

I am not able to reproduce locally. Does it still happen using the latest version?

@OrKoN OrKoN closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants