-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
async_hooks,http: set HTTPParser trigger to socket
This allows more easy tracking of where HTTP requests come from. Before this change the HTTPParser would have the HTTPServer as the triggerAsyncId. The HTTPParser will still have the executionAsyncId set to the HTTP Server so that information is still directly available. Indirectly, the TCP socket itself also has its triggerAsyncId set to the TCP Server. PR-URL: #18003 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]>
- Loading branch information
1 parent
c3fde98
commit 8479606
Showing
3 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const initHooks = require('./init-hooks'); | ||
const verifyGraph = require('./verify-graph'); | ||
const http = require('http'); | ||
|
||
const hooks = initHooks(); | ||
hooks.enable(); | ||
|
||
const server = http.createServer(common.mustCall(function(req, res) { | ||
res.end(); | ||
this.close(common.mustCall()); | ||
})); | ||
server.listen(0, common.mustCall(function() { | ||
http.get(`http://127.0.0.1:${server.address().port}`, common.mustCall()); | ||
})); | ||
|
||
process.on('exit', function() { | ||
hooks.disable(); | ||
|
||
verifyGraph( | ||
hooks, | ||
[ { type: 'TCPSERVERWRAP', | ||
id: 'tcpserver:1', | ||
triggerAsyncId: null }, | ||
{ type: 'TCPWRAP', id: 'tcp:1', triggerAsyncId: 'tcpserver:1' }, | ||
{ type: 'TCPCONNECTWRAP', | ||
id: 'tcpconnect:1', | ||
triggerAsyncId: 'tcp:1' }, | ||
{ type: 'HTTPPARSER', | ||
id: 'httpparser:1', | ||
triggerAsyncId: 'tcpserver:1' }, | ||
{ type: 'HTTPPARSER', | ||
id: 'httpparser:2', | ||
triggerAsyncId: 'tcpserver:1' }, | ||
{ type: 'TCPWRAP', id: 'tcp:2', triggerAsyncId: 'tcpserver:1' }, | ||
{ type: 'Timeout', id: 'timeout:1', triggerAsyncId: 'tcp:2' }, | ||
{ type: 'TIMERWRAP', id: 'timer:1', triggerAsyncId: 'tcp:2' }, | ||
{ type: 'HTTPPARSER', | ||
id: 'httpparser:3', | ||
triggerAsyncId: 'tcp:2' }, | ||
{ type: 'HTTPPARSER', | ||
id: 'httpparser:4', | ||
triggerAsyncId: 'tcp:2' }, | ||
{ type: 'Timeout', | ||
id: 'timeout:2', | ||
triggerAsyncId: 'httpparser:4' }, | ||
{ type: 'TIMERWRAP', | ||
id: 'timer:2', | ||
triggerAsyncId: 'httpparser:4' }, | ||
{ type: 'SHUTDOWNWRAP', | ||
id: 'shutdown:1', | ||
triggerAsyncId: 'tcp:2' } ] | ||
); | ||
}); |