Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: replace HTTPPARSER by new resource names #27372

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/async-hooks/test-graph.http.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ process.on('exit', function() {
{ type: 'TCPCONNECTWRAP',
id: 'tcpconnect:1',
triggerAsyncId: 'tcp:1' },
{ type: 'HTTPPARSER',
{ type: 'HTTPINCOMINGMESSAGE',
id: 'httpparser:1',
triggerAsyncId: 'tcpserver:1' },
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
{ type: 'Timeout', id: 'timeout:1', triggerAsyncId: 'tcp:2' },
{ type: 'HTTPPARSER',
{ type: 'HTTPINCOMINGMESSAGE',
id: 'httpparser:2',
triggerAsyncId: 'tcp:2' },
{ type: 'Timeout',
Expand Down
4 changes: 0 additions & 4 deletions test/async-hooks/test-graph.tls-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ function onexit() {
id: 'getaddrinforeq:1', triggerAsyncId: 'tls:1' },
{ type: 'TCPCONNECTWRAP',
id: 'tcpconnect:1', triggerAsyncId: 'tcp:1' },
{ type: 'WRITEWRAP', id: 'write:1', triggerAsyncId: 'tcpconnect:1' },
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' },
{ type: 'TLSWRAP', id: 'tls:2', triggerAsyncId: 'tcpserver:1' },
{ type: 'WRITEWRAP', id: 'write:2', triggerAsyncId: null },
{ type: 'WRITEWRAP', id: 'write:3', triggerAsyncId: null },
{ type: 'WRITEWRAP', id: 'write:4', triggerAsyncId: null },
{ type: 'Immediate', id: 'immediate:1', triggerAsyncId: 'tcp:2' },
{ type: 'Immediate', id: 'immediate:2', triggerAsyncId: 'tcp:1' },
]
Expand Down
12 changes: 12 additions & 0 deletions test/async-hooks/verify-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ module.exports = function verifyGraph(hooks, graph) {
);
}
assert.strictEqual(errors.length, 0);

// Verify that all expected types are present
const expTypes = Object.create(null);
for (let i = 0; i < graph.length; i++) {
if (expTypes[graph[i].type] == null) expTypes[graph[i].type] = 0;
expTypes[graph[i].type]++;
}

for (const type in expTypes) {
assert.strictEqual(typeSeen[type], expTypes[type],
`Expecting type '${type}' in graph`);
}
};

//
Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-async-hooks-http-parser-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const createdIds = [];
const destroyedIds = [];
async_hooks.createHook({
init: common.mustCallAtLeast((asyncId, type) => {
if (type === 'HTTPPARSER') {
if (type === 'HTTPINCOMINGMESSAGE' || type === 'HTTPCLIENTREQUEST') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does HTTPCLIENTREQUEST ever actually happen here? My messing around with this for another PR has that never showing up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly speaking I haven't looked into this in that detail; my focus was to repair the test and to add an assert to avoid such side effect again.
#26961 is still reproducible after #25094 was merged so there is for sure something left in this but this needs more thoughts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried and it seems HTTPCLIENTREQUEST is never emitted. This is for sure a bug.

createdIds.push(asyncId);
}
}, N),
Expand All @@ -25,7 +25,7 @@ async_hooks.createHook({
}
}).enable();

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

Expand All @@ -35,6 +35,7 @@ const keepAliveAgent = new http.Agent({
});

const countdown = new Countdown(N, () => {
assert.ok(createdIds.length >= N);
server.close(() => {
// Give the server sockets time to close (which will also free their
// associated parser objects) after the server has been closed.
Expand Down