-
Notifications
You must be signed in to change notification settings - Fork 436
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-Message decoding #117
Conversation
f05fe3a
to
3fb1422
Compare
messages are turned into |
3fb1422
to
1c4cdbd
Compare
CI green. |
Review ping. |
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.
Thanks for the PR! Just a few points
ts/src/grpc.ts
Outdated
@@ -231,7 +235,7 @@ export namespace grpc { | |||
const gRPCMessage = headers.get("grpc-message") || []; | |||
props.debug && debug("onHeaders.gRPCMessage", gRPCMessage); | |||
if (code !== Code.OK) { | |||
rawOnError(code, gRPCMessage[0]); | |||
rawOnError(code, gRPCMessage.length > 0 ? decodeURIComponent(gRPCMessage[0]) : undefined); |
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.
decodeURIComponent
can throw URIError
, we should attempt to handle it. Could we also use the ""
(empty string) as the value rather than undefined?
I have reorganized the code to satisfy the requirements. I tried to minimize code duplication, but basically we have to return early if the decode errors and that part cannot be put inside a function. |
Oh, ****, the tests are full of |
2b4aa28
to
9600e71
Compare
This is basically done, but I have no idea why Edge tests are failing. Can you run a retry? |
The Edge tests seem to be flaky, and I'm probably out of luck. Can you retry again? |
@ishitatsuyuki Sorry for the delay on this. Would you mind rebasing the PR? |
Sure, I'll do it tomorrow. |
18c6dd6
to
ce34f88
Compare
@easyCZ I think this is ready for review. |
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.
After the rebase there's now a name
variable which does not exist anymore
test/ts/src/client.spec.ts
Outdated
@@ -351,6 +351,39 @@ describe(`client`, () => { | |||
}); | |||
}); | |||
|
|||
headerTrailerCombos((withHeaders, withTrailers) => { | |||
it("should report status code in Unicode for error with headers + trailers" + name, (done) => { |
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.
The name
variable is not defined.
ce34f88
to
968eb3f
Compare
All green, please review again. |
ts/src/client.ts
Outdated
try { | ||
statusMessage = this.decodeGRPCStatus(gRPCMessage[0]); | ||
} catch (err) { | ||
this.rawOnError(Code.Internal, "Cannot decode gRPC-Message header"); |
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.
Is this the correct error code? Should it be unknown as it is an error on the transport library rather than the end users code?
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.
It's unspecified; maybe it should be Unknown but anyway that only happens when a corrupted/broken message is received. Any reference?
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.
Only from the discussion in #150
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.
Aligned the behavior with grpc-go.
LGTM. |
No description provided.