Skip to content

Commit

Permalink
fix: ignore objectId puppeteer error
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Jan 24, 2024
1 parent 91708d2 commit 706d9c3
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 @@ -10,6 +10,7 @@ const { Hermione } = require("../hermione");
const pkg = require("../../package.json");
const logger = require("../utils/logger");
const { requireModule } = require("../utils/module");
const { shouldIgnoreUnhandledRejection } = require("../utils/errors");

let hermione;

Expand All @@ -19,7 +20,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 (err.message === "Cannot extract value when objectId is given" && 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 706d9c3

Please sign in to comment.