File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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 ( ) ) ;
You can’t perform that action at this time.
0 commit comments