Skip to content

fix: logError logs full error object including cause (#6462)#7296

Closed
ErnestHysa wants to merge 1 commit into
expressjs:masterfrom
ErnestHysa:fix/6462-logError-swallows-cause
Closed

fix: logError logs full error object including cause (#6462)#7296
ErnestHysa wants to merge 1 commit into
expressjs:masterfrom
ErnestHysa:fix/6462-logError-swallows-cause

Conversation

@ErnestHysa
Copy link
Copy Markdown

Description

Fixes #6462 - logError swallows Error.cause

Changes

In lib/application.js, changed:

console.error(err.stack || err.toString())

to:

console.error(err)

Why

When logging err.stack, the Error.cause() chain is lost because stack only contains the stack trace of the specific error, not the cause chain. Logging the full err object allows Node.js to print the complete error including the cause chain, making debugging much easier.

Testing

npm test passes for the application.js related tests.

Fixes expressjs#6462 - logError swallows cause

Changed console.error(err.stack || err.toString()) to console.error(err)
so that the full error including the cause chain is logged properly.
@krzysdz
Copy link
Copy Markdown
Contributor

krzysdz commented Jun 1, 2026

Duplicate of #6464

@krzysdz krzysdz marked this as a duplicate of #6464 Jun 1, 2026
@krzysdz krzysdz closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logError swallows error details (such as cause)

2 participants