mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-07-31 02:12:02 +08:00
fix: finalizer and unhandled promise rejection
This commit is contained in:
parent
eba1f9c0ec
commit
df127d0207
8
package-lock.json
generated
8
package-lock.json
generated
@ -17,7 +17,7 @@
|
||||
"axios": "^1.3.3",
|
||||
"bcrypt": "^5.1.0",
|
||||
"busboy": "^1.6.0",
|
||||
"civkit": "^0.8.4-92aafc5",
|
||||
"civkit": "^0.8.4-ef21ac9",
|
||||
"core-js": "^3.37.1",
|
||||
"cors": "^2.8.5",
|
||||
"dayjs": "^1.11.9",
|
||||
@ -3989,9 +3989,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/civkit": {
|
||||
"version": "0.8.4-92aafc5",
|
||||
"resolved": "https://registry.npmjs.org/civkit/-/civkit-0.8.4-92aafc5.tgz",
|
||||
"integrity": "sha512-Je5DTJs8H3fl3WYBbvKwqTzfUm5NuHt9WIrN3hJ5AHosQWGuyLrQf7N2lKo50aiTJdixEr3NDHqUwQ1KY59yoA==",
|
||||
"version": "0.8.4-ef21ac9",
|
||||
"resolved": "https://registry.npmjs.org/civkit/-/civkit-0.8.4-ef21ac9.tgz",
|
||||
"integrity": "sha512-CAGzSIcXeBbYmhweTBqTqoroIpxI/dH87KhlT6MzokOiMpRcs02NJXM5V/KPbZ5hTqT9jii2xGd1CwsvTYZezg==",
|
||||
"license": "AGPL",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21",
|
||||
|
@ -26,7 +26,7 @@
|
||||
"axios": "^1.3.3",
|
||||
"bcrypt": "^5.1.0",
|
||||
"busboy": "^1.6.0",
|
||||
"civkit": "^0.8.4-92aafc5",
|
||||
"civkit": "^0.8.4-ef21ac9",
|
||||
"core-js": "^3.37.1",
|
||||
"cors": "^2.8.5",
|
||||
"dayjs": "^1.11.9",
|
||||
|
@ -53,7 +53,10 @@ export class BlackHoleDetector extends AsyncService {
|
||||
|
||||
if (this.strikes >= 3) {
|
||||
this.logger.error(`BlackHole detected for ${this.strikes} strikes, last worked: ${Math.ceil(dt / 1000)}s ago, concurrentRequests: ${this.concurrentRequests}`);
|
||||
this.emit('error', new Error(`BlackHole detected for ${this.strikes} strikes, last worked: ${Math.ceil(dt / 1000)}s ago, concurrentRequests: ${this.concurrentRequests}`));
|
||||
process.nextTick(() => {
|
||||
this.emit('error', new Error(`BlackHole detected for ${this.strikes} strikes, last worked: ${Math.ceil(dt / 1000)}s ago, concurrentRequests: ${this.concurrentRequests}`));
|
||||
// process.exit(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,9 @@ export class FinalizerService extends AbstractFinalizerService {
|
||||
super(...arguments);
|
||||
}
|
||||
|
||||
override onUnhandledRejection(err: unknown, _triggeringPromise: Promise<unknown>): void {
|
||||
this.logger.error(`Unhandled promise rejection in pid ${process.pid}`, { err });
|
||||
}
|
||||
}
|
||||
|
||||
const instance = container.resolve(FinalizerService);
|
||||
|
@ -1012,7 +1012,6 @@ export class PuppeteerControl extends AsyncService {
|
||||
}
|
||||
|
||||
let nextSnapshotDeferred = Defer();
|
||||
nextSnapshotDeferred.promise.catch(() => 'just dont crash anything');
|
||||
const crippleListener = () => nextSnapshotDeferred.reject(new ServiceCrashedError({ message: `Browser crashed, try again` }));
|
||||
this.once('crippled', crippleListener);
|
||||
nextSnapshotDeferred.promise.finally(() => {
|
||||
@ -1077,10 +1076,10 @@ export class PuppeteerControl extends AsyncService {
|
||||
}
|
||||
|
||||
this.logger.warn(`Page ${sn}: Browsing of ${url} failed`, { err: marshalErrorLike(err) });
|
||||
return Promise.reject(new AssertionFailureError({
|
||||
return new AssertionFailureError({
|
||||
message: `Failed to goto ${url}: ${err}`,
|
||||
cause: err,
|
||||
}));
|
||||
});
|
||||
}).then(async (stuff) => {
|
||||
// This check is necessary because without snapshot, the condition of the page is unclear
|
||||
// Calling evaluate directly may stall the process.
|
||||
@ -1145,7 +1144,6 @@ export class PuppeteerControl extends AsyncService {
|
||||
);
|
||||
}
|
||||
});
|
||||
gotoPromise.catch(() => 'just dont crash anything');
|
||||
let waitForPromise: Promise<any> | undefined;
|
||||
if (options.waitForSelector) {
|
||||
const t0 = Date.now();
|
||||
|
Loading…
x
Reference in New Issue
Block a user