• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3
4// This test ensures that running vm with breakOnSignt option in multiple
5// worker_threads does not crash.
6// Issue: https://github.com/nodejs/node/issues/43699
7const { Worker } = require('worker_threads');
8const vm = require('vm');
9
10// Don't use isMainThread to allow running this test inside a worker.
11if (!process.env.HAS_STARTED_WORKER) {
12  process.env.HAS_STARTED_WORKER = 1;
13  for (let i = 0; i < 10; i++) {
14    const worker = new Worker(__filename);
15    worker.on('exit', common.mustCall());
16  }
17} else {
18  const ctx = vm.createContext({});
19  for (let i = 0; i < 100; i++) {
20    vm.runInContext('console.log(1)', ctx, { breakOnSigint: true });
21  }
22}
23