-
Notifications
You must be signed in to change notification settings - Fork 295
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
Executing an array returns weird object. #198
Comments
Hi @patriksimek, I quote you as main maintainer. I've this issue too. This happens with VM and with NodeVM. In my case, inside the NodeVM i have a snippet that -among other things- does this:
And prints:
The console in the NodeVM setup is set to Do you have any clue of what could generate this behavior? Thank you in advance and sorry to bother. |
This object turned out to be a Proxy. I believe that somewhere in Decontextify.instance a wrong object is returned. |
Produces expected output under node v8.9.3 and node v8.10.0. |
Ran into this same problem. Frustrating tracking this bug down, thinking it was in my own code. Eventually decided to try a very minimal example and lo and behold, |
What I can propose is to run a debugger in v.8.10.0 and v10.14.2 and find a line of code where the output is different. |
This was caused by using a Proxy.handler.ownKeys() trap. This was an issue in node and seems to be fixed in v12. |
Do you plan any fallback for older versions of node? |
The problem is only on node 10. We could do a fix, but that would require to check the caller of a function every time and to get the caller we would need to generate a stack trace. I think that it is not worth doing this. |
What about a config or CLI parameter check instead? The code for that could be pretty minimal. |
I add |
This is back for all versions as the fix broke |
still same now... |
The issue is actually a V8 bug. See nodejs/node#41714 (comment) |
A work arround for converting the proxy object to a js object (a bit hacky): value = JSON.parse(JSON.stringify(proxy)) |
Code like this:
Prints:
[ 1, 2, 3, '0': 1, '1': 2, '2': 3 ]
Is this a bug or an expected behaviour?
The NodeJS's build in VM returns:
[1, 2, 3]
as expected.
The text was updated successfully, but these errors were encountered: