webcontainer-core
webcontainer-core copied to clipboard
Node `vm.runInNewContext` doesn’t return new context
Describe the bug
Running require('vm').runInNewContext('this')
should return a clean globalThis
without any overridden prototypes. In real Node it does, but in StackBlitz it does not.
Link to the blitz that caused the error
https://stackblitz.com/edit/stackblitz-starters-ta5fme?file=index.cjs
Steps to reproduce
- Go to https://stackblitz.com/edit/stackblitz-starters-ta5fme?file=index.cjs
- Run
node index.cjs
- Observe that the last logged number is 666. If you run this same file in real Node on your local machine, the last logged number is 1.
Expected behavior
The output should be:
Original lastIndexOf: 1
Polluted lastIndexOf: 666
Restored lastIndexOf: 1
Parity with Local
- [X] I have run the project in my local machine and I could not reproduce the issue.
Screenshots
No response
Platform
Browser name = Chrome
Full version = 126.0.0.0
Major version = 126
navigator.appName = Netscape
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
performance.memory = {
"totalJSHeapSize": 84778612,
"usedJSHeapSize": 80715932,
"jsHeapSizeLimit": 4294705152
}
Hash = 70dbe416
Additional context
Related to https://github.com/stackblitz/webcontainer-core/issues/309.