summaryrefslogtreecommitdiff
path: root/test/parallel/test-process-before-exit.js
blob: ec7a7f76e57ef9d063cb47d97eaaffcabd78d937 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'use strict';
require('../common');
const assert = require('assert');

const N = 5;
let n = 0;

function f() {
  if (++n < N) setTimeout(f, 5);
}
process.on('beforeExit', f);
process.on('exit', function() {
  assert.equal(n, N + 1);  // The sixth time we let it through.
});