Skip to content

Error "message" property enumerability change on 9.7.0+ #19716

Closed
@alexjeffburke

Description

@alexjeffburke
  • Version: 9.7.0+
  • Platform: macOS 10.12.6
  • Subsystem: errors

Background
There appears to be a change in the enumerability of the "message" property on at least errors coming up from the getaddrinfo system call that were noticed when a number of tests for the Unexpected project and a number of it's plugins started failing. After looking into and rolling out code changes I was able to beset node versions, and it seems this issue was introduced between 9.6.1 and 9.7.0.

The follwing code should demonstrate the issue:

const dns = require('dns');

dns.lookup('asdfasdfasdfasdfasdfasdfasdf.zzz', (err) => {
    if (!err) return;
    var enumerableKeys = Object.keys(err);
    var hasMessage = enumerableKeys.indexOf('message') > -1;
    console.log(`${err.name} with ${enumerableKeys.length} enumerable keys ${hasMessage ? 'WITH' : 'WITHOUT'} "message"`);
 });

Expected outcome
Both version of node report the same number of enumerable keys and message is not included.

Actual outcome
9.6.1: 'Error with 4 enumerable keys WITHOUT "message"'
9.7.0: 'Error with 5 enumerable keys WITH "message"'

Summary
I hope the above is enough to explain the issue. Based on the workaround we applied, it seems likely that these errors were previously instantiated by passing the message into the constructor but were changed so the message was attached after the fact.

If there's anything else I can provide please let me know.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions