fix: wait-for-selector stalling process

This commit is contained in:
Yanlong Wang 2025-05-07 22:38:50 +08:00
parent da1098f38d
commit 7bc70a1955
No known key found for this signature in database
GPG Key ID: C0A623C0BADF9F37

View File

@ -1210,7 +1210,6 @@ export class PuppeteerControl extends AsyncService {
}
await Promise.race([Promise.allSettled([...pageScriptEvaluations, ...frameScriptEvaluations]), delayPromise])
.catch(() => void 0);
finalizationPromise = doFinalization();
return stuff;
});
if (options.waitForSelector) {
@ -1232,16 +1231,16 @@ export class PuppeteerControl extends AsyncService {
});
return p as any;
});
finalizationPromise = Promise.allSettled([waitForPromise, gotoPromise]).then(doFinalization);
} else {
finalizationPromise = gotoPromise.then(doFinalization);
}
try {
let lastHTML = snapshot?.html;
while (true) {
const ckpt = [nextSnapshotDeferred.promise, gotoPromise];
if (waitForPromise) {
ckpt.push(waitForPromise);
}
const ckpt = [nextSnapshotDeferred.promise, waitForPromise ?? gotoPromise];
if (options.minIntervalMs) {
ckpt.push(delay(options.minIntervalMs));
}