Skip to content

fix: logError now logs full error object including cause#7091

Closed
KJyang-0114 wants to merge 1 commit into
expressjs:masterfrom
KJyang-0114:fix/issue-6462-logError-cause
Closed

fix: logError now logs full error object including cause#7091
KJyang-0114 wants to merge 1 commit into
expressjs:masterfrom
KJyang-0114:fix/issue-6462-logError-cause

Conversation

@KJyang-0114
Copy link
Copy Markdown

Description

Fixes #6462 - logError swallows error details (such as cause)

Problem

When an error with a cause property is logged, only err.stack or err.toString() is logged, which loses:

  • The cause property chain
  • Nested error details
  • Async stack traces

Solution

Change from:

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

To:

console.error(err)

This preserves the full error object including cause, nested errors, and async stack traces.

Testing

Verified that console.error(err) outputs the full error object with all properties intact.

Before: console.error(err.stack || err.toString())
After: console.error(err)

This preserves error.cause, nested errors, and async stack traces
that are lost when using err.stack alone.

Fixes expressjs#6462
@krzysdz
Copy link
Copy Markdown
Contributor

krzysdz commented Mar 8, 2026

Duplicate of #6464

Please don't create the same PR multile times. You opened #7088 yesterday and both PRs are identical (same branch), except for small differences in the AI generated description.

@krzysdz krzysdz closed this Mar 8, 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