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

fix: handle idle socket error #30

Merged
merged 6 commits into from
Mar 13, 2016
Merged

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Mar 12, 2016

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @lattmann, @pmalouin and @dead-horse to be potential reviewers

@fengmk2 fengmk2 changed the title Handle error on free socket fix: handle idle socket error Mar 12, 2016
@fengmk2 fengmk2 force-pushed the handle-error-on-free-socket branch 5 times, most recently from b1fcf60 to e892fd9 Compare March 12, 2016 13:35
// https://github.com/node-modules/agentkeepalive/issues/25
// https://github.com/nodejs/node/pull/4482 (fixed in >= 4.4.0 and >= 5.4.0)
var errorListeners = socket.listeners('error');
if (errorListeners && errorListeners.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

errorListeners 不存在的时候呢?

Copy link
Member Author

Choose a reason for hiding this comment

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

呃,神奇了,看来 listeners 无论如何都会返回一个数组,不存在的时候返回空数组

Copy link
Member Author

Choose a reason for hiding this comment

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

https://github.com/nodejs/node/blob/master/lib/events.js#L399

我改改,不需要判断是否存在了。

@fengmk2 fengmk2 force-pushed the handle-error-on-free-socket branch from e892fd9 to 2fbb3a7 Compare March 13, 2016 13:23
// Add a default error handler to avoid Unhandled 'error' event throw on idle socket
// https://github.com/node-modules/agentkeepalive/issues/25
// https://github.com/nodejs/node/pull/4482 (fixed in >= 4.4.0 and >= 5.4.0)
if (socket.listeners('error').length === 0) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@dead-horse fixed

@fengmk2
Copy link
Member Author

fengmk2 commented Mar 13, 2016

@dead-horse 我合并发布了。

fengmk2 added a commit that referenced this pull request Mar 13, 2016
@fengmk2 fengmk2 merged commit bca85bc into master Mar 13, 2016
@fengmk2 fengmk2 deleted the handle-error-on-free-socket branch March 13, 2016 14:59
@fengmk2
Copy link
Member Author

fengmk2 commented Mar 13, 2016

2.0.4

@dead-horse
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pick handle errors on idle sockets agentkeepalive detecting ECONNRESET
3 participants