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

Fix orphaned browser processes due to uncaught exceptions in the tests #18401

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,6 @@ async function startBrowsers({ baseUrl, initializeSession }) {
await puppeteer.trimCache();

const browserNames = options.noChrome ? ["firefox"] : ["firefox", "chrome"];

sessions = [];
for (const browserName of browserNames) {
// The session must be pushed first and augmented with the browser once
// it's initialized. The reason for this is that browser initialization
Expand Down Expand Up @@ -1078,25 +1076,33 @@ async function main() {
stats = [];
}

try {
if (options.downloadOnly) {
await ensurePDFsDownloaded();
} else if (options.unitTest) {
// Allows linked PDF files in unit-tests as well.
await ensurePDFsDownloaded();
startUnitTest("/test/unit/unit_test.html", "unit");
await startUnitTest("/test/unit/unit_test.html", "unit");
} else if (options.fontTest) {
startUnitTest("/test/font/font_test.html", "font");
await startUnitTest("/test/font/font_test.html", "font");
} else if (options.integration) {
// Allows linked PDF files in integration-tests as well.
await ensurePDFsDownloaded();
startIntegrationTest();
await startIntegrationTest();
} else {
startRefTest(options.masterMode, options.reftest);
await startRefTest(options.masterMode, options.reftest);
}
} catch (e) {
// Close the browsers if uncaught exceptions occur, otherwise the spawned
// processes can become orphaned and keep running after `test.mjs` exits
// because the teardown logic of the tests did not get a chance to run.
console.error(e);
await Promise.all(sessions.map(session => closeSession(session.name)));
}
}

var server;
var sessions;
var sessions = [];
timvandermeij marked this conversation as resolved.
Show resolved Hide resolved
var onAllSessionsClosed;
var host = "127.0.0.1";
var options = parseOptions();
Expand Down