Skip to content

Commit ab20dae

Browse files
committed
fix: reduce error logs for critical errors, omit node:internal and promise logs
1 parent df8da55 commit ab20dae

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/cli/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ process.on("uncaughtException", err => {
2121
process.exit(1);
2222
});
2323

24-
process.on("unhandledRejection", (reason, p) => {
24+
process.on("unhandledRejection", reason => {
2525
// This flag lets other unhandledRejection handlers know that we already processed it on Testplane side.
2626
// Currently we use this to avoid duplicate error logging and force shutdown in HTML Reporter.
2727
(global as Record<string, unknown>)["__TESTPLANE_INTERNAL_UNHANDLED_REJECTION_PROCESSED"] = true;
@@ -32,7 +32,6 @@ process.on("unhandledRejection", (reason, p) => {
3232

3333
const error = [
3434
`Unhandled Rejection in testplane:master:${process.pid}:`,
35-
`Promise: ${utilInspectSafe(p)}`,
3635
`Reason: ${utilInspectSafe(reason)}`,
3736
].join("\n");
3837

src/utils/processor.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ process.on("uncaughtException", err => {
2020
throw err;
2121
});
2222

23-
process.on("unhandledRejection", (reason, p) => {
23+
process.on("unhandledRejection", reason => {
2424
if (shouldIgnoreUnhandledRejection(reason)) {
2525
logger.warn(`Unhandled Rejection "${reason}" in testplane:worker:${process.pid} was ignored`);
2626
return;
2727
}
2828

2929
const error = [
3030
`Unhandled Rejection in testplane:worker:${process.pid}:`,
31-
`Promise: ${utilInspectSafe(p)}`,
3231
`Reason: ${utilInspectSafe(reason)}`,
3332
].join("\n");
3433

src/utils/workers-registry.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ module.exports = class WorkersRegistry extends EventEmitter {
8989
`Check surrounding logs for more details on the cause. If you believe this should not have happened, let us know: ${NEW_ISSUE_LINK}\n\n`,
9090
);
9191
try {
92-
workerCallError.stack = workerCallError.name + stack.split("\n").slice(1).join("\n");
92+
const nodeInternalLinesFilter = line => !/node:internal|node:events|node:domain/.test(line);
93+
workerCallError.stack =
94+
workerCallError.name +
95+
stack.split("\n").slice(1).filter(nodeInternalLinesFilter).join("\n");
96+
error.stack = error.stack.split("\n").filter(nodeInternalLinesFilter).join("\n");
9397
} catch {
9498
/* */
9599
}

0 commit comments

Comments
 (0)