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

http: unref socket timer on parser execute #6286

Closed
wants to merge 3 commits into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Apr 19, 2016

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

http

Description of change

When underlying net.Socket instance is consumed in http server - no
data events are emitted, and thus socket.setTimeout fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling socket._unrefTimer() on every onParserExecute
call.

Fix: #5899

When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: nodejs#5899
@indutny
Copy link
Member Author

indutny commented Apr 19, 2016

@indutny indutny added the http Issues or PRs related to the http subsystem. label Apr 19, 2016
@indutny
Copy link
Member Author

indutny commented Apr 19, 2016

Gosh, timing issues on FreeBSD CI slave. One more try after the fix: https://ci.nodejs.org/job/node-test-pull-request/2327/

@alexjeffburke
Copy link
Contributor

Quick question, does this apply to v4 as well?

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

It does.

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

Thank you!

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

cc @nodejs/http @bnoordhuis @trevnorris @jasnell

assert(false, 'Should not happen');
});
req.resume();
req.once('end', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wrap this in common.mustCall() ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

@jasnell
Copy link
Member

jasnell commented Apr 20, 2016

LGTM with a couple nits in the test.

@alexjeffburke
Copy link
Contributor

@indutny glad if I've helped & thank you for the fix :)

setTimeout(() => {
clearInterval(interval);
req.end();
}, 400);
Copy link
Contributor

@mscdex mscdex Apr 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timeout value should probably be wrapped with common.platformTimeout()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack.

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

@indutny
Copy link
Member Author

indutny commented Apr 20, 2016

Landed in ec2822a, thank you!

@indutny indutny closed this Apr 20, 2016
indutny added a commit that referenced this pull request Apr 20, 2016
When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: #5899
PR-URL: #6286
Reviewed-By: James M Snell <jasnell@gmail.com>
@vixlet-kevin
Copy link

Thanks for the fix!

MylesBorins pushed a commit that referenced this pull request Apr 20, 2016
When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: #5899
PR-URL: #6286
Reviewed-By: James M Snell <jasnell@gmail.com>
This was referenced Apr 21, 2016
MylesBorins pushed a commit that referenced this pull request Apr 21, 2016
When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: #5899
PR-URL: #6286
Reviewed-By: James M Snell <jasnell@gmail.com>
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request Apr 25, 2016
When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: nodejs#5899
PR-URL: nodejs#6286
Reviewed-By: James M Snell <jasnell@gmail.com>
jasnell pushed a commit that referenced this pull request Apr 26, 2016
When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: #5899
PR-URL: #6286
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 17, 2016
When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: #5899
PR-URL: #6286
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 18, 2016
When underlying `net.Socket` instance is consumed in http server - no
`data` events are emitted, and thus `socket.setTimeout` fires the
callback even if the data is constantly flowing into the socket.

Fix this by calling `socket._unrefTimer()` on every `onParserExecute`
call.

Fix: #5899
PR-URL: #6286
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request May 18, 2016
@Trott
Copy link
Member

Trott commented Jul 13, 2016

Looks like FreeBSD timing issues are back with this: #7643

I guess if there was some way to make this not dependent on a timer race, that would have happened, yeah? :-/

@nodejs/testing

@Trott
Copy link
Member

Trott commented Jul 13, 2016

Actually, I think I've fixed it. PR coming soon...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Socket setTimeout behaviour not working as expected for HTTP requests
7 participants