Skip to content

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

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#7088
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

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

The previous code using err.stack loses important error information:

  • Error.cause property (nested errors)
  • Async stack traces
  • Nested errors in Sequelize and other libraries (parent/original properties)

Solution

Change from err.stack || err.toString() to just err, which allows the console to properly format and display the full error object including all nested properties.

Testing

This fix preserves:

  • Error.cause
  • Nested errors (parent, original properties)
  • Async stack traces

See the original issue for concrete examples.

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 7, 2026

Duplicate of #6464

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