Closed
Description
In the case where an incoming HTTP request is consumed by the C++ layer, the resulting parserOnBody
callbacks are not made through MakeCallback
. Instead they use ->Call
directly. In the slow case, where the TCP connection is not consumed by C++, the appropriate pre/post
events are fired.
Given the example program:
const asyncHooks = process.binding('async_wrap');
const http = require('http');
asyncHooks.setupHooks(_ => _, function () {
process._rawDebug('pre', this.constructor.name);
}, function () {
process._rawDebug('post', this.constructor.name);
});
asyncHooks.enable();
const server = http.createServer(req => {
req.on('data', data => {
process._rawDebug('RECV');
});
})
if (process.env.RUN_SLOWLY) {
server.on('connection', conn => {
// unconsume the stream.
conn.on('data', _ => _);
});
}
server.listen(8124);
Running the following:
$ curl -sLi -d@/usr/share/dict/words 'http://localhost:8124'
Produces the following when the program is run with node example.js
:
pre TCP
post TCP
RECV
RECV
RECV
RECV
RECV
RECV
RECV
RECV
...
And the following when the example is run with RUN_SLOWLY=1 node example.js
:
pre TCP
post TCP
pre TCP
post TCP
pre TCP
RECV
post TCP
pre TCP
RECV
post TCP
pre TCP
RECV
post TCP
pre TCP
RECV
post TCP
pre TCP
RECV
post TCP
pre TCP
RECV
post TCP
...