Skip to content

Conversation

@loulin
Copy link
Contributor

@loulin loulin commented Mar 12, 2016

如果不监听请求stream error,当发生客户端网络错误时,node进程会完全崩溃。

Request stream可以对error事件不做任何事情,但是必须监听,否则在某个tick周期就挂掉了。

本次修复并没有直接监听req stream的error事件,而是将stream返回给调用方,由开发者自己处理,因为这种error也会同时出现在response callback。

多次测试可能的错误如下:

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: getaddrinfo ENOTFOUND upload
    at errnoException (dns.js:44:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: connect ECONNREFUSED
    at exports._errnoException (util.js:746:11)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1012:19)

}
onresp(rerr, result, res);
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

实际上在这里加上

req.on('error', function() {});

即可。

@longbai
Copy link
Contributor

longbai commented Mar 12, 2016

LGTM

@longbai
Copy link
Contributor

longbai commented Mar 12, 2016

👍 赞

longbai added a commit that referenced this pull request Mar 12, 2016
fix Unhandled stream error in pipe
@longbai longbai merged commit 7f57471 into qiniu:master Mar 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants