-
Notifications
You must be signed in to change notification settings - Fork 64
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 grpc bugs #40
fix grpc bugs #40
Conversation
smile21
commented
Mar 19, 2019
- 修复 grpc invoke 多次但返回数据相同问题
- 修复grpc server service 用户逻辑抛异常,但调用方长时间无响应问题
Codecov Report
@@ Coverage Diff @@
## master #40 +/- ##
=========================================
- Coverage 98.55% 98.46% -0.1%
=========================================
Files 38 38
Lines 1871 1890 +19
=========================================
+ Hits 1844 1861 +17
- Misses 27 29 +2
Continue to review full report at Codecov.
|
lib/server/grpc/response.js
Outdated
if (methodInfo.responseType) { | ||
const responseEncodeStart = Date.now(); | ||
const responseType = methodInfo.resolvedResponseType; | ||
const buf = responseType.encode(responseType.fromObject(res.appResponse)).finish(); | ||
const resSize = buf.length; | ||
io.position(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.
io.reset()
lib/server/grpc/response.js
Outdated
this.stream.close(http2.constants.NGHTTP2_INTERNAL_ERROR); | ||
} | ||
return; | ||
} |
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.
这里没必要断开吧
lib/server/server.js
Outdated
errorMsg: 'not found service: ' + id, | ||
appResponse: null, | ||
}); | ||
throw new Error('not found service: ' + id); | ||
} else { |
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.
不用 else 了
感谢 PR |
@@ -206,6 +206,7 @@ class Http2CallStream extends Duplex { | |||
} | |||
this._endCall(err); | |||
this.destroy(); | |||
this.emit('close'); |
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.
这个应该不用主动触发吧? destroy 以后会自动触发 close
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.
是的 我的 node 是 v8.x ,在这个版本里 destroy 后收不到 close 事件,所以我手动 emit 了一个
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.
可能和这个 pr 有关 nodejs/node#23654 v8.x 目前还是有这个问题
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.
加一个注释?
}; | ||
let data = ''; | ||
if (res.isError) { | ||
this.meta.rt = Date.now() - this.meta.start; |
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.
rt 可以统一设置