-
Notifications
You must be signed in to change notification settings - Fork 929
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: complete grpc based protocol panic recover handle. #1866
Conversation
Signed-off-by: stonex <[email protected]>
Signed-off-by: stonex <[email protected]>
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.
proxy 有default和PassThrough 都需要考虑一下,是不是将defer放在DefaultProxyImplementFunc中的makeDubboCallProxy里更好一些
Codecov Report
@@ Coverage Diff @@
## 3.0 #1866 +/- ##
==========================================
- Coverage 46.78% 44.80% -1.98%
==========================================
Files 295 283 -12
Lines 17173 16943 -230
==========================================
- Hits 8034 7591 -443
- Misses 8286 8548 +262
+ Partials 853 804 -49
Continue to review full report at Codecov.
|
func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { | ||
result := &protocol.RPCResult{} | ||
func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) (result protocol.Result) { | ||
result = &protocol.RPCResult{} |
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.
不要在返回值处定义变量,容易造成 shadow var。原来的实现挺好的。
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.
这里是为了在出现调用的exception时候,返回result要设置error,要不然没办法返回RPCResult的调用错误信息了。有没有其他方法可以在defer的recover过程中修改返回的结果呢。
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.
改成了在匿名函数里面用defer来获取异常,cc
这个makeDubboCallProxy好像是客户端用的,服务端应该直接调用的是Invoke,我在两个proxy里面都加了异常处理,cc |
retErr = returnValues[1].Interface() | ||
func() { | ||
// Handle invoke exception in user func. | ||
defer func() { |
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.
和default 是一样的defer func, 提取出一个共用的func吧
Signed-off-by: stonex [email protected]
What this PR does:
OnMessage
.Invoke
to prevent the server from hanging up due to the exception .You should pay attention to items below to ensure your pr passes our ci test
We do not merge pr with ci tests failed