-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
domain: fix vm promise tracking while keeping isolation
PR-URL: #43556 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
- Loading branch information
1 parent
e4aa50f
commit 6bcd40d
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const domain = require('domain'); | ||
const vm = require('vm'); | ||
|
||
// A promise created in a VM should not include a domain field but | ||
// domains should still be able to propagate through them. | ||
// | ||
// See; https://github.com/nodejs/node/issues/40999 | ||
|
||
const context = vm.createContext({}); | ||
|
||
function run(code) { | ||
const d = domain.createDomain(); | ||
d.run(common.mustCall(() => { | ||
const p = vm.runInContext(code, context)(); | ||
assert.strictEqual(p.domain, undefined); | ||
p.then(common.mustCall(() => { | ||
assert.strictEqual(process.domain, d); | ||
})); | ||
})); | ||
} | ||
|
||
for (let i = 0; i < 1000; i++) { | ||
run('async () => null'); | ||
} |