Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError produces NodeError with "Please open an issue with this stack trace" #41244

Closed
fabiancook opened this issue Dec 19, 2021 · 4 comments
Closed
Labels
confirmed-bug Issues with confirmed bugs. util Issues and PRs related to the built-in util module.

Comments

@fabiancook
Copy link
Contributor

Version

v17.2.0

Platform

Darwin Fabians-Mac-mini.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64

Subsystem

No response

What steps will reproduce the bug?

By replacing the line here:

https://github.com/virtualstate/x/blob/5e1a4af59fd61b436f02570b1f64ff5a0b90cb79/packages/fringe/src/token.ts#L209

...options?.[TokenAncestor] && ancestor ? (

With

...options[TokenAncestor] && ancestor ? (

And running:

yarn build && node packages/fringe/lib/token.types-test.js

Produces the error.

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

No response

What is the expected behavior?

The error log:

TypeError: Cannot read properties of undefined (reading 'Symbol(@virtualstate/fringe/token/ancestor)')
    at defineProperties (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/token.js:126:23)
    at createToken (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/token.js:57:5)
    at Object.createNode (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/create-node.js:115:26)
    at flattenChildrenSource (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/children.js:154:27)
    at flattenChildrenSource.next (<anonymous>)
    at Object.get [Symbol.iterator] (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/create-node.js:454:37)
    at isIterable (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/node_modules/iterable/dist/core/async-like.js:31:14)
    at isIterableChildren (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/children.js:162:12)
    at flattenChildrenSource (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/children.js:144:38)
    at flattenChildrenSource.next (<anonymous>)

What do you see instead?

The error log:

node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_INTERNAL_ASSERTION]: Error [ERR_INTERNAL_ASSERTION]: TypeError: Cannot read properties of undefined (reading 'Symbol(@virtualstate/fringe/token/ancestor)')
    at defineProperties (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/token.js:126:23)
    at createToken (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/token.js:57:5)
    at Object.createNode (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/create-node.js:115:26)
    at flattenChildrenSource (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/children.js:154:27)
    at flattenChildrenSource.next (<anonymous>)
    at Object.get [Symbol.iterator] (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/create-node.js:454:37)
    at isIterable (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/node_modules/iterable/dist/core/async-like.js:31:14)
    at isIterableChildren (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/children.js:162:12)
    at flattenChildrenSource (file:///Volumes/Extreme/Users/fabian/src/virtualstate/x/packages/fringe/lib/children.js:144:38)
    at flattenChildrenSource.next (<anonymous>)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at new NodeError (node:internal/errors:371:5)
    at Function.fail (node:internal/assert:20:9)
    at handleMaxCallStackSize (node:internal/util/inspect:1370:10)
    at formatRaw (node:internal/util/inspect:1013:12)
    at formatValue (node:internal/util/inspect:793:10)
    at formatProperty (node:internal/util/inspect:1681:11)
    at formatRaw (node:internal/util/inspect:1006:9)
    at formatValue (node:internal/util/inspect:793:10)
    at inspect (node:internal/util/inspect:340:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2006:40)
This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

    at new NodeError (node:internal/errors:371:5)
    at Function.fail (node:internal/assert:20:9)
    at handleMaxCallStackSize (node:internal/util/inspect:1370:10)
    at formatRaw (node:internal/util/inspect:1013:12)
    at formatValue (node:internal/util/inspect:793:10)
    at inspect (node:internal/util/inspect:340:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2006:40)
    at formatWithOptions (node:internal/util/inspect:1888:10)
    at console.value (node:internal/console/constructor:323:14)
    at console.log (node:internal/console/constructor:359:61) {
  code: 'ERR_INTERNAL_ASSERTION'
}

Additional information

I don't actually believe this is a valid bug, but the internal bug asked for me to raise, so I have raised.

@meixg meixg added the util Issues and PRs related to the built-in util module. label Feb 28, 2022
@meixg
Copy link
Member

meixg commented Feb 28, 2022

A minimal reproducible example:

const a = {
    b: {
        get [Symbol.iterator]() {
            throw Error();
        }
    }
};

console.log(a);

This happens because the userland Error is caught by the internal module:

try {
output = formatter(ctx, value, recurseTimes);
for (i = 0; i < keys.length; i++) {
output.push(
formatProperty(ctx, value, recurseTimes, keys[i], extrasType));
}
if (protoProps !== undefined) {
output.push(...protoProps);
}
} catch (err) {
const constructorName = getCtxStyle(value, constructor, tag).slice(0, -1);
return handleMaxCallStackSize(ctx, err, constructorName, indentationLvl);
}

Maybe we can improve this by filtering the userland error?

@cola119
Copy link
Member

cola119 commented Jul 5, 2022

From my reading @meixg's above minimal example causes an error because of the dynamic Symbol.iterator access at L862.

if (value[SymbolIterator] || constructor === null) {

I'm still not sure if @fabiancook's error is happening for the same reason but I'll try to fix it by removing access to Symbol.iterator.

@BridgeAR BridgeAR added the confirmed-bug Issues with confirmed bugs. label Jul 5, 2022
@BridgeAR
Copy link
Member

BridgeAR commented Jul 5, 2022

@meixg it is actually a separate issue that you highlight.

I have a local fix for this issue as well.

@avivkeller
Copy link
Member

This is no longer reproducible AFAICT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

No branches or pull requests

5 participants