Skip to content

Commit

Permalink
Merge pull request #762 from gemini-testing/HERMIONE-818.debug
Browse files Browse the repository at this point in the history
fix: handle unhandled rejections with circular refs on timeout error
  • Loading branch information
DudaGod authored Apr 27, 2023
2 parents d59ac1a + 8c38c66 commit 17d9aa0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"mocha": "^10.2.0",
"plugins-loader": "^1.1.0",
"png-validator": "1.1.0",
"serialize-error": "^8.1.0",
"sharp": "~0.30.7",
"sizzle": "^2.3.6",
"temp": "^0.8.3",
Expand Down
14 changes: 12 additions & 2 deletions src/utils/processor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

const { serializeError, deserializeError } = require("serialize-error");
const { WORKER_UNHANDLED_REJECTION } = require("../constants/process-messages");
const ipc = require("./ipc");

Expand All @@ -15,7 +16,16 @@ module.exports = async (module, methodName, args, cb) => {
try {
const result = await require(module)[methodName](...args);
cb(null, result);
} catch (e) {
cb(e);
} catch (err) {
sendError(err, cb);
}
};

function sendError(err, cb) {
try {
cb(err);
} catch {
const errWithoutCircularRefs = deserializeError(serializeError(err));
cb(errWithoutCircularRefs);
}
}

0 comments on commit 17d9aa0

Please sign in to comment.