-
Notifications
You must be signed in to change notification settings - Fork 58
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
Conversation
By analyzing the blame information on this pull request, we identified @lattmann, @pmalouin and @dead-horse to be potential reviewers |
b1fcf60
to
e892fd9
Compare
// 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errorListeners 不存在的时候呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
呃,神奇了,看来 listeners 无论如何都会返回一个数组,不存在的时候返回空数组
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e892fd9
to
2fbb3a7
Compare
// 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dead-horse fixed
@dead-horse 我合并发布了。 |
2.0.4 |
👍 |
cc @JacksonTian @gxcsoccer @hustxiaoc