Skip to content

Commit

Permalink
fix: ignore objectId puppeteer error (#833)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr authored Jan 24, 2024
1 parent 19eac5b commit 71db82b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions src/utils/errors.ts
Original file line number Diff line number Diff line change
@@ -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;
};
3 changes: 2 additions & 1 deletion src/utils/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 71db82b

Please sign in to comment.