mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-19 06:35:54 +08:00
fix
This commit is contained in:
parent
d2afa9ddc2
commit
33ca16405e
@ -1096,7 +1096,7 @@ export class PuppeteerControl extends AsyncService {
|
|||||||
nextSnapshotDeferred.promise.finally(() => {
|
nextSnapshotDeferred.promise.finally(() => {
|
||||||
this.off('crippled', crippleListener);
|
this.off('crippled', crippleListener);
|
||||||
});
|
});
|
||||||
let successfullyDone = false;
|
let successfullyDone;
|
||||||
const hdl = (s: any) => {
|
const hdl = (s: any) => {
|
||||||
if (snapshot === s) {
|
if (snapshot === s) {
|
||||||
return;
|
return;
|
||||||
@ -1145,9 +1145,12 @@ export class PuppeteerControl extends AsyncService {
|
|||||||
let waitForPromise: Promise<any> | undefined;
|
let waitForPromise: Promise<any> | undefined;
|
||||||
let finalizationPromise: Promise<any> | undefined;
|
let finalizationPromise: Promise<any> | undefined;
|
||||||
const doFinalization = async () => {
|
const doFinalization = async () => {
|
||||||
if (!waitForPromise) {
|
if (waitForPromise) {
|
||||||
successfullyDone = true;
|
// SuccessfullyDone is meant for the finish of the page.
|
||||||
|
// It doesn't matter if you are expecting something and it didn't show up.
|
||||||
|
await waitForPromise.catch(() => void 0);
|
||||||
}
|
}
|
||||||
|
successfullyDone ??= true;
|
||||||
try {
|
try {
|
||||||
const pSubFrameSnapshots = this.snapshotChildFrames(page);
|
const pSubFrameSnapshots = this.snapshotChildFrames(page);
|
||||||
snapshot = await page.evaluate('giveSnapshot(true)') as PageSnapshot;
|
snapshot = await page.evaluate('giveSnapshot(true)') as PageSnapshot;
|
||||||
@ -1222,13 +1225,14 @@ export class PuppeteerControl extends AsyncService {
|
|||||||
page.waitForSelector(options.waitForSelector!, { timeout: thisTimeout }))
|
page.waitForSelector(options.waitForSelector!, { timeout: thisTimeout }))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
successfullyDone = true;
|
successfullyDone = true;
|
||||||
finalizationPromise = doFinalization();
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
waitForPromise = undefined;
|
||||||
this.logger.warn(`Page ${sn}: Failed to wait for selector ${options.waitForSelector}`, { err });
|
this.logger.warn(`Page ${sn}: Failed to wait for selector ${options.waitForSelector}`, { err });
|
||||||
});
|
});
|
||||||
return p as any;
|
return p as any;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user