Skip to content

Commit 05909d0

Browse files
kunalspathakMylesBorins
authored andcommitted
test: fix flaky test-vm-timeout-rethrow
The intention of test case is to make sure that `timeout` property is honored and the code in context terminates and throws correct exception. However in test case, the code inside context would complete before `timeout` for windows and would sometimes fail. Updated the code so it guarantee to not complete execution until timeout is triggered. Fixes: #11261 PR-URL: #11530 Reviewed-By: James M Snell <jasnell.gmail.com> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Josh Gavant <[email protected]>
1 parent a0c705e commit 05909d0

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

test/sequential/test-vm-timeout-rethrow.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@ var vm = require('vm');
55
var spawn = require('child_process').spawn;
66

77
if (process.argv[2] === 'child') {
8-
var code = 'var j = 0;\n' +
9-
'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n' +
10-
'j;';
8+
const code = 'while(true);';
119

12-
var ctx = vm.createContext({
13-
add: function(x, y) {
14-
return x + y;
15-
}
16-
});
10+
const ctx = vm.createContext();
1711

1812
vm.runInContext(code, ctx, { timeout: 1 });
1913
} else {

0 commit comments

Comments
 (0)