FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

http: don't double-fire the req error event by fengmk2 · Pull Request #14333 · nodejs/node · GitHub

/ node Public

http: don't double-fire the req error event - #14333

Closed
fengmk2 wants to merge 1 commit into
nodejs:masterfrom
fengmk2:http-client-req-error-dont-double-fire
Closed

http: don't double-fire the req error event#14333
fengmk2 wants to merge 1 commit into
nodejs:masterfrom
fengmk2:http-client-req-error-dont-double-fire

Conversation

fengmk2 commented Jul 18, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Should set req.socket._hadError to true before emit the error event.

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

http

nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jul 18, 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

These asserts aren't necessary since common.mustCall() already checks that the functions are called exactly the specified number of times (with 1 being the default).

mscdex Jul 18, 2017
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Instead of using a fixed port as-is like this, consider using a custom http.Agent that returns an error in createConnection(). For an example of this, see this commit. This way we don't end up having a potentially flaky test in the future.

fengmk2 force-pushed the http-client-req-error-dont-double-fire branch from 03aa455 to 5e9c272 Compare July 18, 2017 03:46

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@mscdex I use not exists host instead.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

assert is unused now.

fengmk2 force-pushed the http-client-req-error-dont-double-fire branch from 5e9c272 to 934cb88 Compare July 18, 2017 03:52

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

These count variables and console.log()s are no longer needed either IMHO.

fengmk2 force-pushed the http-client-req-error-dont-double-fire branch from 934cb88 to ba8e1b7 Compare July 18, 2017 04:19

fengmk2 commented Jul 18, 2017

Copy link
Copy Markdown
Contributor Author

@mscdex @dead-horse Thanks for the quickly review, all changed.

cjihrig left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with a few suggestions.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think you have to include these first 21 lines in new files.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

const req = http.get({ host }); should fit comfortably on one line.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You should probably verify that the error received here is the same one that is thrown. If you declare the error outside of the req.on('error', ...) block, but still throw it from in there, then you can just use assert.strictEqual() in here.

Should set req.socket._hadError to true before emit the error event.
fengmk2 force-pushed the http-client-req-error-dont-double-fire branch from ba8e1b7 to c4b1a86 Compare July 20, 2017 13:14

fengmk2 commented Jul 20, 2017

Copy link
Copy Markdown
Contributor Author

@cjihrig done!

fengmk2 commented Jul 25, 2017

Copy link
Copy Markdown
Contributor Author

@mscdex @cjihrig can we land this fix at the next node version release?

mscdex commented Jul 25, 2017

Copy link
Copy Markdown
Contributor

fengmk2 commented Aug 2, 2017

Copy link
Copy Markdown
Contributor Author

@mscdex need to restart ci task.

mscdex commented Aug 2, 2017

Copy link
Copy Markdown
Contributor

jasnell commented Aug 3, 2017

Copy link
Copy Markdown
Member

Any idea on the semver-iness of this change? I'd prefer it not to be major but it may have to be. Thoughts?

cjihrig commented Aug 4, 2017

Copy link
Copy Markdown
Contributor

I'd prefer patch I think.

fengmk2 commented Aug 7, 2017

Copy link
Copy Markdown
Contributor Author

@jasnell I think this change is a bugfix.

jasnell commented Aug 8, 2017

Copy link
Copy Markdown
Member

Works for me

Copy link
Copy Markdown
Member

Landed in 620ba41.

tniessen closed this Aug 16, 2017
tniessen referenced this pull request Aug 16, 2017
req.socket._hadError should be set before emitting the error event.

PR-URL: #14659
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
fengmk2 deleted the http-client-req-error-dont-double-fire branch October 18, 2017 15:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

7 participants


Back | FazBrowse Home | New Git URL