Skip to content

http: handle cases where socket.server is null - #13578

Closed
lpinca wants to merge 2 commits into
nodejs:masterfrom
lpinca:gh-13435
Closed

http: handle cases where socket.server is null#13578
lpinca wants to merge 2 commits into
nodejs:masterfrom
lpinca:gh-13435

Conversation

@lpinca

@lpincalpinca commented Jun 9, 2017

Copy link
Copy Markdown
Member

Fixes a regression that caused an error to be thrown when trying to emit the 'timeout' event on the server referenced by socket.server.

Fixes: #13435
Refs: #11926

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

http

@nodejs-github-botnodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jun 9, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any chance you can give the test a more descriptive name?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I copied the format of the existing regression tests. Any suggestion? Can only think of something like test-http-socket-server-not-null which seems as obscure as the current one.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then perhaps add a comment that describes the purpose of the test?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Does test-cluster-send-net-socket-to-worker-http-server work for you?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe shorten a bit to test-cluster-send-socket-to-worker-server, but it's up to you.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Done, thanks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you achieve the same thing without a timeout? It will probably become flakey in the CI.

@lpincalpincaJun 9, 2017

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Sure, I used the timeout to actually test that socketOnTimeout() is called but checking that socket.server is correctly set should work as well.

Fixes a regression that caused an error to be thrown when trying to
emit the 'timeout' event on the server referenced by `socket.server`.
Fixes: nodejs#13435
Refs: nodejs#11926

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you use disconnect() here.

@lpinca

Copy link
Copy Markdown
MemberAuthor

@lpincalpinca mentioned this pull request Jun 10, 2017
@addaleax

Copy link
Copy Markdown
Member

Landed in ba449f3

addaleax pushed a commit that referenced this pull request Jun 12, 2017
Fixes a regression that caused an error to be thrown when trying to
emit the 'timeout' event on the server referenced by `socket.server`.
Fixes: #13435
Refs: #11926
PR-URL: #13578
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@lpinca
lpinca deleted the gh-13435 branch June 12, 2017 12:16
addaleax pushed a commit that referenced this pull request Jun 12, 2017
Fixes a regression that caused an error to be thrown when trying to
emit the 'timeout' event on the server referenced by `socket.server`.
Fixes: #13435
Refs: #11926
PR-URL: #13578
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax added a commit that referenced this pull request Jun 12, 2017
* **Child processes**
* `stdout` and `stderr` are now available on the error output of a
failed call to the `util.promisify()`ed version of
`child_process.exec`.
[[`d66d4fc94c`](d66d4fc94c)]
[#13388](#13388)
* **HTTP**
* A regression that broke certain scenarios in which HTTP is used together
with the `cluster` module has been fixed.
[[`fff8a56d6f`](fff8a56d6f)]
[#13578](#13578)
* **HTTPS**
* The `rejectUnauthorized` option now works properly for unix sockets.
[[`c4cbd99d37`](c4cbd99d37)]
[#13505](#13505)
* **Readline**
* A change that broke `npm init` and other code which uses `readline`
multiple times on the same input stream is reverted.
[[`0df6c0b5f0`](0df6c0b5f0)]
[#13560](#13560)
PR-URL: #13598
addaleax added a commit that referenced this pull request Jun 12, 2017
* **Child processes**
* `stdout` and `stderr` are now available on the error output of a
failed call to the `util.promisify()`ed version of
`child_process.exec`.
[[`d66d4fc94c`](d66d4fc94c)]
[#13388](#13388)
* **HTTP**
* A regression that broke certain scenarios in which HTTP is used together
with the `cluster` module has been fixed.
[[`fff8a56d6f`](fff8a56d6f)]
[#13578](#13578)
* **HTTPS**
* The `rejectUnauthorized` option now works properly for unix sockets.
[[`c4cbd99d37`](c4cbd99d37)]
[#13505](#13505)
* **Readline**
* A change that broke `npm init` and other code which uses `readline`
multiple times on the same input stream is reverted.
[[`0df6c0b5f0`](0df6c0b5f0)]
[#13560](#13560)
PR-URL: #13598
addaleax added a commit that referenced this pull request Jun 12, 2017
* **Child processes**
* `stdout` and `stderr` are now available on the error output of a
failed call to the `util.promisify()`ed version of
`child_process.exec`.
[[`d66d4fc94c`](d66d4fc94c)]
[#13388](#13388)
* **HTTP**
* A regression that broke certain scenarios in which HTTP is used together
with the `cluster` module has been fixed.
[[`fff8a56d6f`](fff8a56d6f)]
[#13578](#13578)
* **HTTPS**
* The `rejectUnauthorized` option now works properly for unix sockets.
[[`c4cbd99d37`](c4cbd99d37)]
[#13505](#13505)
* **Readline**
* A change that broke `npm init` and other code which uses `readline`
multiple times on the same input stream is reverted.
[[`0df6c0b5f0`](0df6c0b5f0)]
[#13560](#13560)
PR-URL: #13598
MylesBorins pushed a commit that referenced this pull request Jun 13, 2017
* **Child processes**
* `stdout` and `stderr` are now available on the error output of a
failed call to the `util.promisify()`ed version of
`child_process.exec`.
[[`d66d4fc94c`](d66d4fc94c)]
[#13388](#13388)
* **HTTP**
* A regression that broke certain scenarios in which HTTP is used together
with the `cluster` module has been fixed.
[[`fff8a56d6f`](fff8a56d6f)]
[#13578](#13578)
* **HTTPS**
* The `rejectUnauthorized` option now works properly for unix sockets.
[[`c4cbd99d37`](c4cbd99d37)]
[#13505](#13505)
* **Readline**
* A change that broke `npm init` and other code which uses `readline`
multiple times on the same input stream is reverted.
[[`0df6c0b5f0`](0df6c0b5f0)]
[#13560](#13560)
PR-URL: #13598
jasnell pushed a commit that referenced this pull request Jun 13, 2017
* **Child processes**
* `stdout` and `stderr` are now available on the error output of a
failed call to the `util.promisify()`ed version of
`child_process.exec`.
[[`d66d4fc94c`](d66d4fc94c)]
[#13388](#13388)
* **HTTP**
* A regression that broke certain scenarios in which HTTP is used together
with the `cluster` module has been fixed.
[[`fff8a56d6f`](fff8a56d6f)]
[#13578](#13578)
* **HTTPS**
* The `rejectUnauthorized` option now works properly for unix sockets.
[[`c4cbd99d37`](c4cbd99d37)]
[#13505](#13505)
* **Readline**
* A change that broke `npm init` and other code which uses `readline`
multiple times on the same input stream is reverted.
[[`0df6c0b5f0`](0df6c0b5f0)]
[#13560](#13560)
PR-URL: #13598
@gibfahngibfahn mentioned this pull request Jun 15, 2017
3 tasks
@MylesBorins

Copy link
Copy Markdown
Contributor

do we want to backport this to v6.x?

@lpinca

Copy link
Copy Markdown
MemberAuthor

@MylesBorins no it's not needed.

@magicode

magicode commented Nov 15, 2017

Copy link
Copy Markdown

@lpinca

why this

if(socket.server===null)socket.server=this;

this is best

if(!socket.server)socket.server=this;//or socket.server=socket.server&&this;

i am move from node6 to mode8 and i get undefined error

_http_server.js:393
var serverTimeout = this.server.emit('timeout', this);
^
TypeError: Cannot read property 'emit' of undefined
at TLSSocket.socketOnTimeout (_http_server.js:393:35)

@lpinca

Copy link
Copy Markdown
MemberAuthor

@magicode If I remember correctly it was because it is set to null when the socket is created.

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

Labels

httpIssues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

passing socket from master to worker causes a timeout issue where socket is null.

7 participants

@lpinca@addaleax@MylesBorins@magicode@jasnell@cjihrig@nodejs-github-bot