xref: /third_party/node/test/parallel/test-worker-terminate-unrefed.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst { once } = require('events');
41cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// Test that calling worker.terminate() on an unref()’ed Worker instance
71cb0ef41Sopenharmony_ci// still resolves the returned Promise.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciasync function test() {
101cb0ef41Sopenharmony_ci  const worker = new Worker('setTimeout(() => {}, 1000000);', { eval: true });
111cb0ef41Sopenharmony_ci  await once(worker, 'online');
121cb0ef41Sopenharmony_ci  worker.unref();
131cb0ef41Sopenharmony_ci  await worker.terminate();
141cb0ef41Sopenharmony_ci}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_citest().then(common.mustCall());
17

Indexes created Thu Nov 07 10:32:03 CST 2024