xref: /third_party/node/test/parallel/test-domain-timers-uncaught-exception.js (revision 1cb0ef41)
  • 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_ci
41cb0ef41Sopenharmony_ci// This test ensures that the timer callbacks are called in the order in which
51cb0ef41Sopenharmony_ci// they were created in the event of an unhandled exception in the domain.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst domain = require('domain').create();
81cb0ef41Sopenharmony_ciconst assert = require('assert');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_cilet first = false;
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cidomain.run(function() {
131cb0ef41Sopenharmony_ci  setTimeout(() => { throw new Error('FAIL'); }, 1);
141cb0ef41Sopenharmony_ci  setTimeout(() => { first = true; }, 1);
151cb0ef41Sopenharmony_ci  setTimeout(() => { assert.strictEqual(first, true); }, 2);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  // Ensure that 2 ms have really passed
181cb0ef41Sopenharmony_ci  let i = 1e6;
191cb0ef41Sopenharmony_ci  while (i--);
201cb0ef41Sopenharmony_ci});
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cidomain.once('error', common.mustCall((err) => {
231cb0ef41Sopenharmony_ci  assert(err);
241cb0ef41Sopenharmony_ci  assert.strictEqual(err.message, 'FAIL');
251cb0ef41Sopenharmony_ci}));
26

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