Skip to content
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

Node 4 breaks making 16kb or greater requests #2821

Closed
geek opened this issue Sep 11, 2015 · 10 comments
Closed

Node 4 breaks making 16kb or greater requests #2821

geek opened this issue Sep 11, 2015 · 10 comments
Labels
confirmed-bug Issues with confirmed bugs. http Issues or PRs related to the http subsystem.

Comments

@geek
Copy link
Member

geek commented Sep 11, 2015

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();
@ChALkeR ChALkeR added http Issues or PRs related to the http subsystem. confirmed-bug Issues with confirmed bugs. labels Sep 11, 2015
@ChALkeR
Copy link
Member

ChALkeR commented Sep 11, 2015

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

@ChALkeR
Copy link
Member

ChALkeR commented Sep 11, 2015

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.

@evanlucas
Copy link
Contributor

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

@ChALkeR
Copy link
Member

ChALkeR commented Sep 11, 2015

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

@indutny
Copy link
Member

indutny commented Sep 11, 2015

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.

indutny added a commit to indutny/io.js that referenced this issue Sep 11, 2015
Socket resume may happen on a next tick, and in following scenario:

1. `socket.resume()`
2. `socket._handle.close()`
3. `socket._handle = null;`

The `_resume` will be invoked with empty `._handle` property. There is
nothing bad about it, and we should just ignore the `resume`/`pause`
events in this case.

Same applies to the unconsuming of socket on adding `data` and/or
`readable` event listeners.

Fix: nodejs#2821
@indutny
Copy link
Member

indutny commented Sep 11, 2015

Fix is here: #2824

@ChALkeR
Copy link
Member

ChALkeR commented Sep 11, 2015

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.

indutny added a commit that referenced this issue Sep 15, 2015
Socket resume may happen on a next tick, and in following scenario:

1. `socket.resume()`
2. `socket._handle.close()`
3. `socket._handle = null;`

The `_resume` will be invoked with empty `._handle` property. There is
nothing bad about it, and we should just ignore the `resume`/`pause`
events in this case.

Same applies to the unconsuming of socket on adding `data` and/or
`readable` event listeners.

Fix: #2821

PR-URL: #2824
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@Fishrock123
Copy link
Contributor

Should be fixed in 7ec0491

indutny added a commit that referenced this issue Sep 15, 2015
Socket resume may happen on a next tick, and in following scenario:

1. `socket.resume()`
2. `socket._handle.close()`
3. `socket._handle = null;`

The `_resume` will be invoked with empty `._handle` property. There is
nothing bad about it, and we should just ignore the `resume`/`pause`
events in this case.

Same applies to the unconsuming of socket on adding `data` and/or
`readable` event listeners.

Fix: #2821

PR-URL: #2824
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
indutny added a commit that referenced this issue Sep 15, 2015
Socket resume may happen on a next tick, and in following scenario:

1. `socket.resume()`
2. `socket._handle.close()`
3. `socket._handle = null;`

The `_resume` will be invoked with empty `._handle` property. There is
nothing bad about it, and we should just ignore the `resume`/`pause`
events in this case.

Same applies to the unconsuming of socket on adding `data` and/or
`readable` event listeners.

Fix: #2821

PR-URL: #2824
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
@Fishrock123
Copy link
Contributor

Fixed in 7ec0491, to be released soon.

@geek
Copy link
Member Author

geek commented Sep 15, 2015

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

ryzokuken added a commit to ryzokuken/node that referenced this issue Mar 28, 2018
Rename test-dgram-regress-4496 to test-dgram-typeerror-buffer to test-dgram-send-invalid-msg-type
Rename test-http-regr-nodejsgh-2821 to test-http-request-large-payload
Rename test-child-process-fork-regr-nodejsgh-2847 to test-child-process-fork-closed-channel-segfault
Rename test-http-pipeline-regr-2639 to test-http-pipeline-serverresponse-assertionerror
Rename test-http-pipeline-regr-3332 to test-http-pipeline-requests-connection-leak
Rename test-http-pipeline-regr-3508 to test-http-pipeline-socket-parser-typeerror

Refs: nodejs#19105
Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants