endo icon indicating copy to clipboard operation
endo copied to clipboard

Where the Node console gets confused if `constructor` is an accessor

Open erights opened this issue 4 years ago • 3 comments

Following in the vscode debugger, I found where the Node inspector gets confused if a constructor is an accessor rather than data property. In something/internal/util/inspect.js I see

    const descriptor = ObjectGetOwnPropertyDescriptor(obj, 'constructor');
    if (descriptor !== undefined &&
        typeof descriptor.value === 'function' &&
        descriptor.value.name !== '' &&
        tmp instanceof descriptor.value) {

@bmeck @michaelfig @kumavis @kriskowal Where do I find the actual source for this, so I can file a PR to fix this to work with constructors than have been made accessors in order to work around the override mistake?

@kumavis this is why {errorTaming: 'unsafe', consoleTaming: 'unsafe'} causes the built-in node console to print those errors as {}. Try changing to {errorTaming: 'unsafe', consoleTaming: 'unsafe', overrideTaming: 'min'} and you'll see your stack traces. Try changing to

{
  errorTaming: 'unsafe', 
  consoleTaming: 'unsafe', 
  overrideTaming: 'min',
  stackFiltering: 'verbose',
}

and you'll see the full original stack traces.

Btw, I strongly recommend against {consoleTaming: 'unsafe'}. Is there a reason you want to turn that on?

erights avatar Mar 25 '21 03:03 erights

See #944

erights avatar Dec 01 '21 03:12 erights

See https://github.com/endojs/endo/issues/2908

erights avatar Aug 12 '25 04:08 erights

The snippet above has grown into the code at

https://github.com/nodejs/node/blob/fc3f19ef932444e8de5d69fe3fb5033b2e0ec2e4/lib/internal/util/inspect.js#L627

If the prototypes whose constructors we make into accessors were added to wellKnownPrototypes, our problems my well disappear.

erights avatar Aug 12 '25 05:08 erights