-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
AsyncWrap: HTTP has no handle context #3241
Comments
Unfortunately getting around this requires knowing implementation details, but here's an example: 'use strict';
const http = require('http');
const async_wrap = process.binding('async_wrap');
const print = process._rawDebug;
let client;
function init(p, parent) {
if (parent) client = this;
}
function noop() { }
async_wrap.setupHooks(init, noop, noop);
async_wrap.enable();
const server = http.createServer(function(req, res) {
// Print if this client matches the init w/ parent.
print(req.client._handle === client);
res.end('hello world');
});
server.listen(0, 'localhost', function() {
// Disable listening to simply test.
async_wrap.disable();
http.get('http://localhost:' + server.address().port + '/', (res) => {
res.resume();
res.once('end', () => server.close());
});
}); This demonstrates that the client handle for a given http request can still be retrieved. Though this is not ideal. I'll look into propagating this information during the HTTPParser phase. One issue with your test is that it will exit on cases like |
It should work the same as TCP if you listened for the http server's |
Sorry I don't follow you.
I think we are on the same page here, but just to be sure. One of my goals is to write a long-stack-trace tool, that doesn't require any extra interaction from the user except adding |
Closed by #5419 |
may need to reopen unless I can fix a regression the patch introduced... |
When creating a simple HTTPserver and connecting to it one looses the handle context. Meaning there is no way to know what handle or callback created the new handle.
Note that this issues exists even after applying #3216 (adds parent to init hook)
complete test case: https://gist.github.com/AndreasMadsen/f56bbdbcd18a2c6358f3
dprof dump: http://bl.ocks.org/AndreasMadsen/raw/6c460eb0e7d6eeadb31a/
/cc @trevnorris
The text was updated successfully, but these errors were encountered: