mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 12:54:43 +00:00

Verify that the destroy callback for a TCP server is called before exit if it is closed in another destroy callback. Fixes: https://github.com/nodejs/node/issues/13262 PR-URL: https://github.com/nodejs/node/pull/13369 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
28 lines
734 B
JavaScript
28 lines
734 B
JavaScript
'use strict';
|
|
|
|
// Regression test for https://github.com/nodejs/node/issues/13262
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const async_hooks = require('async_hooks');
|
|
|
|
let seenId, seenResource;
|
|
|
|
async_hooks.createHook({
|
|
init: common.mustCall((id, provider, triggerId, resource) => {
|
|
seenId = id;
|
|
seenResource = resource;
|
|
assert.strictEqual(provider, 'Immediate');
|
|
assert.strictEqual(triggerId, 1);
|
|
}),
|
|
before: common.mustNotCall(),
|
|
after: common.mustNotCall(),
|
|
destroy: common.mustCall((id) => {
|
|
assert.strictEqual(seenId, id);
|
|
})
|
|
}).enable();
|
|
|
|
const immediate = setImmediate(common.mustNotCall());
|
|
assert.strictEqual(immediate, seenResource);
|
|
clearImmediate(immediate);
|