-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Changed behaviour for instanceof ArrayBuffer
#20978
Comments
This is because the You can reproduce this error by passing any builtin for example if you pass
This is correct behaviour - I'm not sure why Node.js 8 behaved differently. |
I'm not 100% sure, but it seems to me that @Zirro is right. I couldn't see why their script logs |
@advanceddeveloper thank you for weighing in. If both In general - I'm not sure what bug we had in Node.js 8 - but the v10 behavior is definitely more correct. As a tangent - there are several proposals by TC39 to make this into a language (rather than Node.js) feature - https://github.com/tc39/proposal-realms |
My expectation is that if you call |
btw if this is a bug, it is fixed in V8 6.7. |
Very interesting, thanks for looking into this. Going by the description, this commit seems relevant: v8/v8@c68f863 |
Due to a presumed V8 bug, expected to be fixed in future versions. See: nodejs/node#20978
Due to a presumed V8 bug, expected to be fixed in future versions. See: nodejs/node#20978
If we can confirm this as a bug per the above, could this potentially be fixed in a future 10.x release by backporting the relevant commits from V8? |
Can you check if it's fixed in Node 10.4.0? We upgraded V8 in this version |
Thanks, it has indeed been fixed in v10.4.0! I'll leave the issue open in case you want to add documentation about this as well, but otherwise you can close it. |
The issue with `instanceof ArrayBuffer` was fixed in Node.js v10.4.0. See: nodejs/node#20978
The issue with `instanceof ArrayBuffer` was fixed in Node.js v10.4.0. See: nodejs/node#20978
…e to a nodes sandbox issue See nodejs/node#20978, marked as fixed, but seems to resurface with node 10.15.3 and jest 24.7.1
@targos this is happening again as of Node v11.15.0; inside Jest I'm getting |
@abonander Unable to reproduce the issue on v11.15.0. Please note that this issue is related to the Consider the following example: const vm = require('vm');
const ctx = {
console,
buffer: new Uint8Array().buffer,
f(){
ctx.Uint8Array = Uint8Array;
ctx.ArrayBuffer = ArrayBuffer;
},
};
vm.createContext(ctx);
const script = new vm.Script(`
console.log(new Uint8Array().buffer instanceof ArrayBuffer);
console.log(buffer instanceof ArrayBuffer);
f();
console.log(new Uint8Array().buffer instanceof ArrayBuffer);
console.log(buffer instanceof ArrayBuffer);
`);
script.runInContext(ctx); Prior to v10.4.0 it printed
and after the issue is fixed it prints:
Note that it still prints |
This sounds like a Jest bug then because it doesn't give the user control over the VM context as far as I know. |
This comment has been minimized.
This comment has been minimized.
1 similar comment
This helped me: jestjs/jest#7780 (comment) |
Happening in Node 12.14.1. |
and v14.13.0 |
vm
Starting with the release of Node v10, we have seen a new behaviour with
instanceof ArrayBuffer
in jsdom. Our extensive use of thevm
module is presumably involved.I have extracted the following test case from the code in jsdom:
In Node v8.11.2, this logs
true
. In Node v10.2.1, it logsfalse
.I can't say for certain that the new behaviour is wrong - the assignments to
this
in Window were originally added to resolve issues with globals from different contexts, and removing them fixes this particular issue in Node v10. However, doing so reintroduces the previously mentioned issues as well.The text was updated successfully, but these errors were encountered: