diff --git a/lib/xpc/execute_process.js b/lib/xpc/execute_process.js index f3027c6a3..0703e9018 100644 --- a/lib/xpc/execute_process.js +++ b/lib/xpc/execute_process.js @@ -53,7 +53,7 @@ process.on("message", (req) => { } } const request = Hub.ActionRequest.fromIPC(req); - winston.error(`Error on child: ${errorString}. WebhookID: ${request.webhookId}`); + winston.error(`Received Error on child in queue: ${errorString}. WebhookID: ${request.webhookId}`); process.send({ success: false, message: errorString }); }); }); diff --git a/lib/xpc/extended_execute_process.js b/lib/xpc/extended_execute_process.js index 797c4d2e7..12800674c 100644 --- a/lib/xpc/extended_execute_process.js +++ b/lib/xpc/extended_execute_process.js @@ -23,10 +23,26 @@ process.on("message", (req) => { let errorString; if (err instanceof Error) { errorString = err.message || err.toString(); + if (errorString === "{}") { + winston.debug("err.message or err.toString() for Error instance resulted in '{}'. Using a more descriptive fallback."); + errorString = "Unnamed Error"; + } } else if (typeof err === "object" && err !== null) { try { - errorString = JSON.stringify(err); + if (Object.prototype.hasOwnProperty.call(err, "message") && typeof (err).message === "string") { + errorString = (err).message; + } + else { + const stringified = JSON.stringify(err); + if (stringified === "{}" || stringified === "[]") { + winston.debug("Error stringified into {}"); + errorString = err.toString(); + } + else { + errorString = stringified; + } + } } catch (jsonError) { errorString = `[Object could not be stringified: ${jsonError.message || jsonError.toString()}]`; @@ -34,9 +50,13 @@ process.on("message", (req) => { } else { errorString = String(err); + if (errorString === "{}") { + winston.debug("String(err) resulted in '{}'. Using a generic representation for non-object error."); + errorString = "Unnamed Error"; + } } const request = Hub.ActionRequest.fromIPC(req); - winston.error(`Error on child: ${errorString}. WebhookID: ${request.webhookId}`); + winston.error(`Received Error on child in extended queue: ${errorString}. WebhookID: ${request.webhookId}`); process.send({ success: false, message: errorString }); }); }); diff --git a/src/xpc/execute_process.ts b/src/xpc/execute_process.ts index ed327f9ce..0121ba24a 100644 --- a/src/xpc/execute_process.ts +++ b/src/xpc/execute_process.ts @@ -50,7 +50,7 @@ process.on("message", (req) => { } } const request = Hub.ActionRequest.fromIPC(req) - winston.error(`Error on child: ${errorString}. WebhookID: ${request.webhookId}`) + winston.error(`Received Error on child in queue: ${errorString}. WebhookID: ${request.webhookId}`) process.send!({success: false, message: errorString}) }) }) diff --git a/src/xpc/extended_execute_process.ts b/src/xpc/extended_execute_process.ts index 51b3abbce..707984def 100644 --- a/src/xpc/extended_execute_process.ts +++ b/src/xpc/extended_execute_process.ts @@ -25,17 +25,35 @@ process.on("message", (req) => { let errorString if (err instanceof Error) { errorString = err.message || err.toString() + if (errorString === "{}") { + winston.debug("err.message or err.toString() for Error instance resulted in '{}'. Using a more descriptive fallback.") + errorString = "Unnamed Error" + } } else if (typeof err === "object" && err !== null) { try { - errorString = JSON.stringify(err) + if (Object.prototype.hasOwnProperty.call(err, "message") && typeof (err).message === "string") { + errorString = (err).message + } else { + const stringified = JSON.stringify(err) + if (stringified === "{}" || stringified === "[]") { + winston.debug("Error stringified into {}") + errorString = err.toString() + } else { + errorString = stringified + } + } } catch (jsonError: any) { errorString = `[Object could not be stringified: ${jsonError.message || jsonError.toString()}]` } } else { errorString = String(err) + if (errorString === "{}") { + winston.debug("String(err) resulted in '{}'. Using a generic representation for non-object error.") + errorString = "Unnamed Error" + } } const request = Hub.ActionRequest.fromIPC(req) - winston.error(`Error on child: ${errorString}. WebhookID: ${request.webhookId}`) + winston.error(`Received Error on child in extended queue: ${errorString}. WebhookID: ${request.webhookId}`) process.send!({success: false, message: errorString}) - }) + }) })