1'use strict'; 2 3const common = require('../common'); 4const assert = require('assert'); 5const domain = require('domain'); 6const vm = require('vm'); 7 8// A promise created in a VM should not include a domain field but 9// domains should still be able to propagate through them. 10// 11// See; https://github.com/nodejs/node/issues/40999 12 13const context = vm.createContext({}); 14 15function run(code) { 16 const d = domain.createDomain(); 17 d.run(common.mustCall(() => { 18 const p = vm.runInContext(code, context)(); 19 assert.strictEqual(p.domain, undefined); 20 p.then(common.mustCall(() => { 21 assert.strictEqual(process.domain, d); 22 })); 23 })); 24} 25 26for (let i = 0; i < 1000; i++) { 27 run('async () => null'); 28} 29