Promise hooks don't work well in vm contexts
After #36394, the following test is broken:
const vm = require('vm'); const { AsyncLocalStorage } = require('async_hooks') const context = vm.createContext({ AsyncLocalStorage, console, }); vm.runInContext(` const storage = new AsyncLocalStorage() async function test() { return storage.run({ test: 'vm' }, async () => { console.log(storage.getStore()); await 42; console.log(storage.getStore()); }); } test() `, context); const storage = new AsyncLocalStorage() async function test() { return storage.run({ test: 'main context' }, async () => { console.log(storage.getStore()); await 42; console.log(storage.getStore()); }); } test()
Node 16.1.0:
{ test: 'vm' }
{ test: 'main context' }
{ test: 'vm' }
{ test: 'main context' }
Node 16.2.0:
{ test: 'vm' }
{ test: 'main context' }
undefined
{ test: 'main context' }