mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
PR-URL: https://github.com/nodejs/node/pull/60150 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
31 lines
713 B
JavaScript
31 lines
713 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const {
|
|
executionAsyncResource,
|
|
executionAsyncId,
|
|
createHook,
|
|
} = require('async_hooks');
|
|
const http = require('http');
|
|
|
|
const hooked = {};
|
|
createHook({
|
|
init(asyncId, type, triggerAsyncId, resource) {
|
|
hooked[asyncId] = resource;
|
|
},
|
|
}).enable();
|
|
|
|
const server = http.createServer((req, res) => {
|
|
res.end('ok');
|
|
});
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]);
|
|
|
|
http.get({ port: server.address().port }, common.mustCall(() => {
|
|
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]);
|
|
server.close();
|
|
}));
|
|
}));
|