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