Skip to content

fix: logError now logs the full error object (cause, parent, original)#7311

Closed
neocrev wants to merge 1 commit into
expressjs:masterfrom
neocrev:main
Closed

fix: logError now logs the full error object (cause, parent, original)#7311
neocrev wants to merge 1 commit into
expressjs:masterfrom
neocrev:main

Conversation

@neocrev

@neocrev neocrev commented Jun 11, 2026

Copy link
Copy Markdown

Description

Fixes #6462

Problem

The logError function currently uses:

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

This drops all custom error properties that are not part of the stack trace, including:

  • Error.cause (nested errors)
  • Sequelize's parent and original properties
  • Any other custom properties attached to error objects

Fix

Changed to:

console.error(err)

console.error() already prints the stack trace for Error objects, and additionally includes all enumerable properties (cause, parent, original, etc.). This is the standard recommended approach in Node.js and matches how logging libraries handle errors.

Verification

  • console.error(new Error("outer", { cause: new Error("inner") })) prints the full error with cause
  • Sequelize errors now show parent and original properties in the log

Closes #6462

… properties

Using console.error(err.stack || err.toString()) drops Error.cause,
Sequelize parent/original, and other custom properties.
console.error(err) logs the complete error object including nested details.

Fixes #6462
@krzysdz

krzysdz commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Duplicate of #6464

@krzysdz krzysdz marked this as a duplicate of #6464 Jun 11, 2026
@krzysdz krzysdz closed this Jun 11, 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