mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 07:11:00 +02:00
Merge pull request #21333 from calixteman/fix_test_timeout
Recover the browser session on test timeout to keep running subsequent tests
This commit is contained in:
commit
e7661983f7
@ -423,15 +423,38 @@ async function startRefTest(masterMode, showRefImages) {
|
||||
checkRefsTmp();
|
||||
}
|
||||
|
||||
function handleSessionTimeout(session) {
|
||||
if (session.closed) {
|
||||
async function handleSessionTimeout(session) {
|
||||
if (session.closed || session.recovering) {
|
||||
return;
|
||||
}
|
||||
const inflightIds = Object.keys(session.tasks);
|
||||
const suffix = inflightIds.length > 0 ? ` (${inflightIds.join(", ")})` : "";
|
||||
console.log(
|
||||
`${TEST_UNEXPECTED_FAIL} | test failed ${session.name} has not responded in ${browserTimeout}s`
|
||||
`${TEST_UNEXPECTED_FAIL} | test failed ${session.name} has not responded in ${browserTimeout}s${suffix}`
|
||||
);
|
||||
session.numErrors += session.remaining;
|
||||
session.remaining = 0;
|
||||
session.taskResults = {};
|
||||
session.tasks = {};
|
||||
|
||||
monitorBrowserTimeout(session, null);
|
||||
if (session.page) {
|
||||
session.recovering = true;
|
||||
try {
|
||||
await session.page.reload({
|
||||
timeout: browserTimeout * 1000,
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
session.recovering = false;
|
||||
monitorBrowserTimeout(session, handleSessionTimeout);
|
||||
return;
|
||||
} catch (err) {
|
||||
console.log(
|
||||
`Failed to reload ${session.name} after timeout: ${err.message}`
|
||||
);
|
||||
session.recovering = false;
|
||||
}
|
||||
}
|
||||
closeSession(session.name);
|
||||
}
|
||||
|
||||
@ -768,9 +791,15 @@ async function handleWsBinaryResult(data) {
|
||||
const { browser, id, round, page, failure, lastPageNum, numberOfTasks } =
|
||||
meta;
|
||||
const session = getSession(browser);
|
||||
if (!session || session.closed) {
|
||||
return;
|
||||
}
|
||||
monitorBrowserTimeout(session, handleSessionTimeout);
|
||||
|
||||
const taskResults = session.taskResults[id];
|
||||
if (!taskResults) {
|
||||
return;
|
||||
}
|
||||
if (!taskResults[round]) {
|
||||
taskResults[round] = [];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user