Skip to content

Commit

Permalink
fixup!
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed May 5, 2024
1 parent 55f0830 commit fdf899c
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions test/async-hooks/test-async-exec-resource-http-agent.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
'use strict';

const assert = require('assert');
require('../common');

const assert = require('node:assert');
const {
executionAsyncResource,
executionAsyncId,
createHook,
} = require('async_hooks');
const http = require('http');
} = require('node:async_hooks');
const http = require('node:http');

const hooked = {};
createHook({
init(asyncId, type, triggerAsyncId, resource) {
hooked[asyncId] = resource;
}
},
}).enable();

const agent = new http.Agent({
maxSockets: 1
});
maxSockets: 1,
});

const server = http.createServer((req, res) => {
res.end('ok');
});

server.listen(0, () => {
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]);
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]);

http.get({ agent, port: server.address().port }, () => {
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]);
server.close();
agent.destroy();
});
http.get({ agent, port: server.address().port }, () => {
assert.strictEqual(executionAsyncResource(), hooked[executionAsyncId()]);
server.close();
agent.destroy();
});
});

0 comments on commit fdf899c

Please sign in to comment.