Skip to content

util: fix inspection of errors with tampered stack property for node v10 #33948

Closed
@analog-nico

Description

@analog-nico

This is an error report for node v10 which has already been fixed for node v12 and may make sense to fix in node v10 as well. The fix in node v12 could have been made via pull request #30576 .

  • Version: 10.21.0
  • Platform: Mac OS X
  • Subsystem: util

What steps will reproduce the bug?

'use strict'

let util = require('util')

let err1 = new Error()
let err2 = new Error()

err2.stack = String(err2.stack).split('\n') // This breaks it.

util.inspect(err1) // -> OK
util.inspect(err2) // -> OK
util.inspect({ err1 }) // -> OK
util.inspect({ err2 }) // -> TypeError: formatError(...).replace is not a function

How often does it reproduce? Is there a required condition?

Every time in node v10.21.0. Never in node v12.16.1.

What is the expected behavior?

The err2.stack array is inspected as an array would usually be inspected.

What do you see instead?

util.inspect({ err2 }) throws this error: TypeError: formatError(...).replace is not a function

Additional information

Feel free to close if such a fix is not within the scope of the LTS maintenance phase in which node v10 is currently in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions