Skip to content

Maximum call stack size exceeded on util.attachProtoDeep with circular references #338

@patrickpilch

Description

@patrickpilch

There's a stack overflow when applying the node-config prototypes to the following javascript configuration file:

module.exports = {
  "test": {
    "innerProp": process.stdout
  }
}

Code to trigger:

const config = require('config');
config.get('test');

It appears to me like util.attachProtoDeep is unable to handle circular references. From what I can see, this is the chain that's causing the stack to overflow:

+----------------------+
|process.stdout.stream <-----+
+----------+-----------+     |
           |                 |
           v                 |
     +-----+--------+        |
     |stream._handle|        |
     +-------+------+        |
             |               |
             v               |
      +------+------+        |
      |_handle.owner+--------+
      +-------------+

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