Sitelet https://github.com/nodejs/node/issues/2821
Skip to content

Node 4 breaks making 16kb or greater requests #2821

Description

@geek

Related to this PR: #2355
In iojs 3.2.0 the following code works, in iojs 3.3.0 and node 4 the following code throws an error.

var Http = require('http');
var Url = require('url');

var server = Http.createServer(function (req, res) {

    res.writeHead(200);
    res.end();
});
server.listen(8080);

var uri = Url.parse('http://localhost:8080/');
uri.method = 'post';
var req = Http.request(uri);

var payload = new Array(1640).join('0123456789');
req.write(payload);
req.end();

Error:

_http_server.js:515
  this._handle.readStart();
              ^

TypeError: Cannot read property 'readStart' of null
    at Socket.onSocketResume (_http_server.js:515:15)
    at emitNone (events.js:67:13)
    at Socket.emit (events.js:166:7)
    at resume_ (_stream_readable.js:712:10)
    at doNTCallback2 (node.js:429:9)
    at process._tickCallback (node.js:343:17)

If you change the payload size to just under 16kb it works:

var Http = require('http');
var Url = require('url');

var server = Http.createServer(function (req, res) {

    res.writeHead(200);
    res.end();
});
server.listen(8080);

var uri = Url.parse('http://localhost:8080/');
uri.method = 'post';
var req = Http.request(uri);

var payload = new Array(1639).join('0123456789');
req.write(payload);
req.end();

Activity

  1. added
    httpIssues and PRs related to the http subsystem.
    confirmed-bugIssues and PRs for confirmed bugs.
    on Sep 11, 2015
  2. ChALkeR commented on Sep 11, 2015

    @ChALkeR
    Member

    First bad commit is 1bc4468 (#2355).
    cc @indutny @trevnorris

  3. ChALkeR commented on Sep 11, 2015

    @ChALkeR
    Member

    Btw, the description is a bit incorrect:
    new Array(1639).join('0123456789') — ok.
    new Array(1640).join('0123456789') — fail.
    new Array(6644).join('0123456789') — fail.
    new Array(6545).join('0123456789') — ok.

  4. evanlucas commented on Sep 11, 2015

    @evanlucas
    Contributor

    Strange, I can't get it to actually throw. It just hangs for me. On which OS are we seeing this?

  5. ChALkeR commented on Sep 11, 2015

    @ChALkeR
    Member

    @evanlucas Mine — Arch Linux x86_64, both self-built and official binaries.

  6. indutny commented on Sep 11, 2015

    @indutny
    Member

    There is definitely a bug, confirmed on my mac. The fix is easy, I just want to be sure that all edge cases are covered.

  7. indutny commented on Sep 11, 2015

    @indutny
    Member

    Fix is here: #2824

  8. ChALkeR commented on Sep 11, 2015

    @ChALkeR
    Member

    It (the original issue, not the fix that was just added) fails on payload lengths exactly from 2^14 to 2^16 - 1. 2^14 is the first bad payload size, 2^16 is the first good payload size after that.

    After that, 4481602 is the next bad payload size. That gives a request error, not the server crash.

  9. Fishrock123 commented on Sep 15, 2015

    @Fishrock123
    Contributor

    Should be fixed in 7ec0491

  10. Fishrock123 commented on Sep 15, 2015

    @Fishrock123
    Contributor

    Fixed in 7ec0491, to be released soon.

  11. geek commented on Sep 15, 2015

    @geek
    MemberAuthor

    @Fishrock123 thanks for helping to get this in for 4.0.1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.httpIssues and PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions