Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore objectId puppeteer error #833

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading