You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
in operator not working correctly when using Proxy as VM context #30985
The in operator does not work correctly when using a Proxy as a VM context.
varo={};varp=newProxy(o,{has(target,key){console.log('has',key);returnReflect.has(target,key);},get(target,key,receiver){console.log('get',key);returnReflect.get(target,key,receiver);},});vm.createContext(p);vm.runInContext(`this.abcInThis = 'abc' in this`,p);console.log(JSON.stringify(o));// Prints {"abcInThis":false}
In the above code, the expected output is:
has abc
{"abcInThis":false}
but the actual output is:
get abc
{"abcInThis":true}
If we remove the get(target, key, receiver) function, the still incorrect output is:
changed the title [-]`in` operator not working correctly when using Proxy as VM sandbox[/-][+]`in` operator not working correctly when using Proxy as VM context[/+]on Dec 16, 2019
I recently took a pretty deep dive into V8 internals to see what it would take to make fix this issue, and the quick answer is quite a lot. The good news is that V8 will need to update the internal global proxy infrastructure for the proposed realms api when they implement it, which will make it easier to fix this issue.
constvm=require('vm');varo={};varp=newProxy(o,{has(target,key){console.log('has',key);returnReflect.has(target,key);},get(target,key,receiver){console.log('get',key);returnReflect.get(target,key,receiver);},});vm.createContext(p);vm.runInContext(`this.abcInThis = 'abc' in this`,p);console.log(JSON.stringify(o));// Prints {"abcInThis":false}
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
This issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
Activity
[-]`in` operator not working correctly when using Proxy as VM sandbox[/-][+]`in` operator not working correctly when using Proxy as VM context[/+]devsnek commentedon Dec 16, 2019
This is a limitation of V8. See: #22390
I'd be interested in fixing this at some point.
ExE-Boss commentedon Feb 15, 2020
This also causes issues when using the
withoperator, which prevents merging jsdom/webidl2js#167.devsnek commentedon Feb 15, 2020
I recently took a pretty deep dive into V8 internals to see what it would take to make fix this issue, and the quick answer is quite a lot. The good news is that V8 will need to update the internal global proxy infrastructure for the proposed realms api when they implement it, which will make it easier to fix this issue.
ExE-Boss commentedon Feb 16, 2020
See also: #17465
Fix event handler ObjectEnvironment instantiation
avivkeller commentedon Jul 11, 2024
Still reproducible.
Sorry for the mis-close.
ExE-Boss commentedon Jul 12, 2024
@redyetidev
abcInThisshould befalse, so this is still reproducible.avivkeller commentedon Jul 12, 2024
Oh yes, I had it backwards, my bad, sorry.
targos commentedon Sep 12, 2025
I don't know if we can consider this fixed in Node.js v22 and v24, because:
{"abcInThis":false}as expectedhas abcgithub-actions commentedon Jun 27, 2026
This issue has been marked as stale due to 210 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
ExE-Boss commentedon Jun 28, 2026
/keepalive
github-actions commentedon Sep 28, 2026
This issue has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.
ExE-Boss commentedon Sep 28, 2026
/keepalive