mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

Instead of creating new timer - reuse the timer from the freelist. This won't make the freelist timer active for the duration of `uv_close()`, and will let the event-loop exit properly. Fix: #1264 PR-URL: https://github.com/nodejs/node/pull/3407 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
21 lines
355 B
JavaScript
21 lines
355 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
var once = 0;
|
|
|
|
process.on('beforeExit', () => {
|
|
if (once > 1)
|
|
throw new RangeError('beforeExit should only have been called once!');
|
|
|
|
setTimeout(() => {}, 1).unref();
|
|
once++;
|
|
});
|
|
|
|
process.on('exit', (code) => {
|
|
if (code !== 0) return;
|
|
|
|
assert.strictEqual(once, 1);
|
|
});
|