xref: /third_party/node/test/parallel/test-timers-unrefd-interval-still-fires.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci// Regression test for https://github.com/nodejs/node-v0.x-archive/issues/8900.
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ciconst TEST_DURATION = common.platformTimeout(1000);
61cb0ef41Sopenharmony_cilet N = 3;
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst keepOpen =
91cb0ef41Sopenharmony_ci  setTimeout(
101cb0ef41Sopenharmony_ci    common.mustNotCall('Test timed out. keepOpen was not canceled.'),
111cb0ef41Sopenharmony_ci    TEST_DURATION);
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciconst timer = setInterval(common.mustCall(() => {
141cb0ef41Sopenharmony_ci  if (--N === 0) {
151cb0ef41Sopenharmony_ci    clearInterval(timer);
161cb0ef41Sopenharmony_ci    timer._onTimeout =
171cb0ef41Sopenharmony_ci      common.mustNotCall('Unrefd interval fired after being cleared');
181cb0ef41Sopenharmony_ci    clearTimeout(keepOpen);
191cb0ef41Sopenharmony_ci  }
201cb0ef41Sopenharmony_ci}, N), 1);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_citimer.unref();
23

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