From 36d92b25f84b5f4c0af080ec768200a5acada5fc Mon Sep 17 00:00:00 2001 From: Jonathan Fulton Date: Sat, 31 Jan 2026 18:47:41 -0500 Subject: [PATCH] fix: preserve error details like cause in logerror Changed logerror to use console.error(err) instead of console.error(err.stack || err.toString()) to preserve error details like the Error.cause property and other custom error properties. Modern JavaScript errors (ES2022+) support the 'cause' property for error chaining, which was being lost when only logging the stack. Fixes #6462 --- lib/application.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/application.js b/lib/application.js index 838b882aaae..e00e8b61f22 100644 --- a/lib/application.js +++ b/lib/application.js @@ -608,13 +608,17 @@ app.listen = function listen() { /** * Log error using console.error. * + * Logs the full error object to preserve details like `cause` property + * and other custom error properties that would be lost when only + * logging the stack trace. + * * @param {Error} err * @private */ function logerror(err) { /* istanbul ignore next */ - if (this.get('env') !== 'test') console.error(err.stack || err.toString()); + if (this.get('env') !== 'test') console.error(err); } /**