Skip to content

Commit 71db82b

Browse files
authored
fix: ignore objectId puppeteer error (#833)
1 parent 19eac5b commit 71db82b

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/cli/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const info = require("./info");
99
const Hermione = require("../hermione");
1010
const pkg = require("../../package.json");
1111
const logger = require("../utils/logger");
12+
const { shouldIgnoreUnhandledRejection } = require("../utils/errors");
1213

1314
let hermione;
1415

@@ -18,7 +19,7 @@ process.on("uncaughtException", err => {
1819
});
1920

2021
process.on("unhandledRejection", (reason, p) => {
21-
if (reason && reason.name === "ProtocolError") {
22+
if (shouldIgnoreUnhandledRejection(reason)) {
2223
logger.warn(`Unhandled Rejection "${reason}" in hermione:master:${process.pid} was ignored`);
2324
return;
2425
}

src/utils/errors.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const shouldIgnoreUnhandledRejection = (err: Error | undefined): boolean => {
2+
if (!err) {
3+
return false;
4+
}
5+
6+
if (err.name === "ProtocolError") {
7+
return true;
8+
}
9+
10+
if (/Cannot extract value when objectId is given/.test(err.message) && err.stack?.includes("/puppeteer-core/")) {
11+
return true;
12+
}
13+
14+
return false;
15+
};

src/utils/processor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const _ = require("lodash");
44
const { WORKER_UNHANDLED_REJECTION } = require("../constants/process-messages");
55
const logger = require("./logger");
66
const ipc = require("./ipc");
7+
const { shouldIgnoreUnhandledRejection } = require("./errors");
78

89
process.on("unhandledRejection", (reason, p) => {
9-
if (reason && reason.name === "ProtocolError") {
10+
if (shouldIgnoreUnhandledRejection(reason)) {
1011
logger.warn(`Unhandled Rejection "${reason}" in hermione:worker:${process.pid} was ignored`);
1112
return;
1213
}

0 commit comments

Comments
 (0)