Skip to content
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

Make gRPC status codes consistent with gRPC-Go #150

Merged
merged 1 commit into from
Mar 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/ts/src/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ describe(`client`, () => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers);
// Some browsers return empty Headers for failed requests
assert.strictEqual(statusMessage, "Response closed without headers");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.ok(!didGetOnMessage);
done();
});
Expand Down Expand Up @@ -411,7 +411,7 @@ describe(`client`, () => {
client.onEnd((status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers);
assert.strictEqual(statusMessage, "Response closed without grpc-status (Headers only)");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.ok(!didGetOnMessage);
done();
});
Expand Down Expand Up @@ -440,7 +440,7 @@ describe(`client`, () => {
client.onEnd((status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers);
assert.strictEqual(statusMessage, "Response closed without headers");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.ok(!didGetOnMessage);
done();
});
Expand Down
6 changes: 3 additions & 3 deletions test/ts/src/invoke.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ describe("invoke", () => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers);
// Some browsers return empty Headers for failed requests
assert.strictEqual(statusMessage, "Response closed without headers");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.ok(!didGetOnMessage);
done();
}
Expand Down Expand Up @@ -370,7 +370,7 @@ describe("invoke", () => {
onEnd: (status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers);
assert.strictEqual(statusMessage, "Response closed without grpc-status (Headers only)");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.ok(!didGetOnMessage);
done();
}
Expand Down Expand Up @@ -398,7 +398,7 @@ describe("invoke", () => {
onEnd: (status: grpc.Code, statusMessage: string, trailers: grpc.Metadata) => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "trailers", trailers);
assert.strictEqual(statusMessage, "Response closed without headers");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.ok(!didGetOnMessage);
done();
}
Expand Down
6 changes: 3 additions & 3 deletions test/ts/src/unary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe(`unary`, () => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "headers", headers, "res", message, "trailers", trailers);
// Some browsers return empty Headers for failed requests
assert.strictEqual(statusMessage, "Response closed without headers");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
done();
}
});
Expand All @@ -232,7 +232,7 @@ describe(`unary`, () => {
onEnd: ({status, statusMessage, headers, message, trailers}) => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "headers", headers, "res", message, "trailers", trailers);
assert.strictEqual(statusMessage, "Response closed without grpc-status (Headers only)");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.deepEqual(headers.get("grpc-status"), []);
assert.deepEqual(headers.get("grpc-message"), []);
done();
Expand All @@ -252,7 +252,7 @@ describe(`unary`, () => {
onEnd: ({status, statusMessage, headers, message, trailers}) => {
DEBUG && debug("status", status, "statusMessage", statusMessage, "headers", headers, "res", message, "trailers", trailers);
assert.strictEqual(statusMessage, "Response closed without headers");
assert.strictEqual(status, grpc.Code.Internal);
assert.strictEqual(status, grpc.Code.Unknown);
assert.isNull(message);
done();
}
Expand Down
4 changes: 2 additions & 2 deletions ts/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class GrpcClient<TRequest extends ProtobufMessage, TResponse extends ProtobufMes
if (this.responseTrailers === undefined) {
if (this.responseHeaders === undefined) {
// The request was unsuccessful - it did not receive any headers
this.rawOnError(Code.Internal, "Response closed without headers");
this.rawOnError(Code.Unknown, "Response closed without headers");
return;
}

Expand All @@ -162,7 +162,7 @@ class GrpcClient<TRequest extends ProtobufMessage, TResponse extends ProtobufMes
this.props.debug && debug("grpc.headers only response ", grpcStatus, grpcMessage);

if (grpcStatus === null) {
this.rawOnEnd(Code.Internal, "Response closed without grpc-status (Headers only)", this.responseHeaders);
this.rawOnEnd(Code.Unknown, "Response closed without grpc-status (Headers only)", this.responseHeaders);
return;
}

Expand Down