Skip to content

Commit

Permalink
feat: add basic unhandled rejection stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Nov 30, 2023
1 parent 35159c8 commit 5b1db43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";

const _ = require("lodash");
const { Command } = require("@gemini-testing/commander");
const escapeRe = require("escape-string-regexp");

Expand All @@ -23,9 +24,11 @@ process.on("unhandledRejection", (reason, p) => {
return;
}

const error = `Unhandled Rejection in hermione:master:${process.pid}:\nPromise: ${JSON.stringify(
p,
)}\nReason: ${reason}`;
const error = [
`Unhandled Rejection in hermione:master:${process.pid}:`,
`Promise: ${JSON.stringify(p)}`,
`Reason: ${_.get(reason, "stack", reason)}`,
].join("\n");

if (hermione) {
hermione.halt(error);
Expand Down
8 changes: 5 additions & 3 deletions src/utils/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ process.on("unhandledRejection", (reason, p) => {
return;
}

const error = `Unhandled Rejection in hermione:worker:${process.pid}:\nPromise: ${JSON.stringify(
p,
)}\nReason: ${reason}`;
const error = [
`Unhandled Rejection in hermione:worker:${process.pid}:`,
`Promise: ${JSON.stringify(p)}`,
`Reason: ${_.get(reason, "stack", reason)}`,
].join("\n");

ipc.emit(WORKER_UNHANDLED_REJECTION, { error });
});
Expand Down

0 comments on commit 5b1db43

Please sign in to comment.