Skip to content

Backpressure on http.ServerResponse #10256

@davedoesdev

Description

@davedoesdev
  • Version: v6.9.2
  • Platform: Linux david-Latitude-E6440 4.8.0-27-generic docs: added a the #29-Ubuntu SMP Thu Oct 20 21:03:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: http, stream

Here's a test program:

var http = require('http'),
    PassThrough = require('stream').PassThrough,
    server = http.createServer();

server.on('request', function (req, res)
{
    console.log('REQUEST');
    
    var pthru = new PassThrough();

    pthru.on('end', function ()
    {
        console.log("PASSTHROUGH END");
    });

    pthru.pipe(res);

    pthru.end(new Buffer(1024*1024));
});

server.listen(8700, function ()
{
    http.request(
    {
        port: 8700,
        method: 'GET'
    }, function (res)
    {
        console.log('RESPONSE');

        res.on('end', function ()
        {
            console.log("RESPONSE END");
        });
    }).end();
});

I expected it to display:

REQUEST
RESPONSE

because the client-side isn't reading from the response so back-pressure should be applied via res to pthru.

However, it actually displays:

REQUEST
PASSTHROUGH END
RESPONSE

I think maybe I'm missing something, or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions