Skip to content

Commit ce8435b

Browse files
ericrannaudtargos
authored andcommitted
test: testcase demonstrating issue 59541
Check that we lose the execution flow in the outer context, upon resolving a promise created in in the inner context. PR-URL: #59801 Fixes: #59541 Refs: https://issues.chromium.org/issues/441679231 Refs: https://groups.google.com/g/v8-dev/c/YIeRg8CUNS8/m/rEQdFuNZAAAJ Refs: https://tc39.es/ecma262/#sec-newpromiseresolvethenablejob Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 396cc8e commit ce8435b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Flags: --experimental-vm-modules
2+
'use strict';
3+
4+
// https://github.com/nodejs/node/issues/59541
5+
//
6+
// Promises created in a context using microtaskMode: "aferEvaluate" (meaning it
7+
// has its own microtask queue), when resolved in the surrounding context, will
8+
// schedule a task back onto the inner context queue.
9+
10+
const common = require('../common');
11+
const vm = require('vm');
12+
13+
const microtaskMode = 'afterEvaluate';
14+
15+
(async () => {
16+
const mustNotCall1 = common.mustNotCall();
17+
const mustNotCall2 = common.mustNotCall();
18+
19+
const inner = {};
20+
21+
const context = vm.createContext({ inner }, { microtaskMode });
22+
23+
const module = new vm.SourceTextModule(
24+
'inner.promise = Promise.resolve();',
25+
{ context },
26+
);
27+
28+
await module.link(mustNotCall1);
29+
await module.evaluate();
30+
31+
// This is Issue 59541, the next statement is not executed, of course
32+
// it should be.
33+
mustNotCall2();
34+
})().then(common.mustNotCall());

0 commit comments

Comments
 (0)