Closed
Description
The implementation of the vm
module has some limitation that results in non-intuitive behaviour. There are already a few bugs open for this (see list below). At this point I do not think there are incremental fixes that can solve the issues with the vm
module. I suspect that a revamp of the vm module might be needed, with some API help from the V8 team, to fix these issues properly.
Existing open issues:
- vm: references to context inside objects are not === the original context #855: references to context inside objects are not === the original context
- vm: accessor properties get converted to data properties inside the vm #2734: accessor properties get converted to data properties
- sandbox inheritied properties flattened after vm.runInNewContext #5350: inherited properties get flattened
- Proxy passed as vm context hides built-in properties. #6158: Proxy passed as vm context hides built-in properties
- VM: weird behaviour in runInContext/runInThisContext #5344: Strict mode global property update should not succeed
- VM context object silently fails on Object.defineProperty #5679: Object.defineProperty
- [code comment] Async updates in context aren't reflected in the sandbox object.
- Function redefinition in vm.runInContext #548, fixed upstream in V8 (September 2016)
- vm misses const definitions after recursive loads (only in v0.11.15) node-v0.x-archive#9084 (but it may be a dupe of VM top level vars are lost after a few iterations #769 which was fixed in recent V8)
- deleting property in vm context has no effect #6287 deleting a property in a context has no effect
- Built-in properties cannot be accessed using Reflect, when Proxy is passed as vm context #7458 Built-in properties cannot be accessed using Reflect, when Proxy is passed as vm context
- vm: strict mode ReferenceError with assignment to context property #12300 vm: strict mode ReferenceError with assignment to context property
- probably more that I am not aware of... (please add in comments below and I will update the issue)
I am creating this issue to make it easier to keep track of these issues, and possible solutions.
/cc @nodejs/v8 @domenic.