diff --git a/src/cli/index.js b/src/cli/index.js index d3af1382f..b5adafbf3 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -9,6 +9,7 @@ const info = require("./info"); const Hermione = require("../hermione"); const pkg = require("../../package.json"); const logger = require("../utils/logger"); +const { shouldIgnoreUnhandledRejection } = require("../utils/errors"); let hermione; @@ -18,7 +19,7 @@ process.on("uncaughtException", err => { }); process.on("unhandledRejection", (reason, p) => { - if (reason && reason.name === "ProtocolError") { + if (shouldIgnoreUnhandledRejection(reason)) { logger.warn(`Unhandled Rejection "${reason}" in hermione:master:${process.pid} was ignored`); return; } diff --git a/src/utils/errors.ts b/src/utils/errors.ts new file mode 100644 index 000000000..03120e0e4 --- /dev/null +++ b/src/utils/errors.ts @@ -0,0 +1,15 @@ +export const shouldIgnoreUnhandledRejection = (err: Error | undefined): boolean => { + if (!err) { + return false; + } + + if (err.name === "ProtocolError") { + return true; + } + + if (/Cannot extract value when objectId is given/.test(err.message) && err.stack?.includes("/puppeteer-core/")) { + return true; + } + + return false; +}; diff --git a/src/utils/processor.js b/src/utils/processor.js index 28c36fa1d..637cab906 100644 --- a/src/utils/processor.js +++ b/src/utils/processor.js @@ -4,9 +4,10 @@ const _ = require("lodash"); const { WORKER_UNHANDLED_REJECTION } = require("../constants/process-messages"); const logger = require("./logger"); const ipc = require("./ipc"); +const { shouldIgnoreUnhandledRejection } = require("./errors"); process.on("unhandledRejection", (reason, p) => { - if (reason && reason.name === "ProtocolError") { + if (shouldIgnoreUnhandledRejection(reason)) { logger.warn(`Unhandled Rejection "${reason}" in hermione:worker:${process.pid} was ignored`); return; }