Skip to content

Commit

Permalink
Fix error detail debug property (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Sep 10, 2024
1 parent ed63cee commit 552d40b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
7 changes: 5 additions & 2 deletions packages/connect-conformance/src/callback-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
ServerStreamRequest,
UnimplementedRequest,
IdempotentUnaryRequest,
ConformancePayload,
} from "./gen/connectrpc/conformance/v1/service_pb.js";
import {
convertToProtoError,
Expand All @@ -37,6 +38,8 @@ import { ConformanceService } from "./gen/connectrpc/conformance/v1/service_conn

type ConformanceClient = CallbackClient<typeof ConformanceService>;

const emptyPayload = new ConformancePayload();

export function invokeWithCallbackClient(
transport: Transport,
req: ClientCompatRequest,
Expand Down Expand Up @@ -82,7 +85,7 @@ async function unary(
if (err !== undefined) {
setClientErrorResult(result, err);
} else {
result.payloads.push(response.payload!);
result.payloads.push(response.payload ?? emptyPayload);
}
resolve(result);
},
Expand Down Expand Up @@ -125,7 +128,7 @@ async function serverStream(
const clientCancelFn = client.serverStream(
getSingleRequestMessage(compatRequest, ServerStreamRequest),
(response) => {
result.payloads.push(response.payload!);
result.payloads.push(response.payload ?? emptyPayload);
if (result.payloads.length === cancelTiming.afterNumResponses) {
clientCancelled = true;
clientCancelFn();
Expand Down
13 changes: 8 additions & 5 deletions packages/connect-conformance/src/promise-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import {
BidiStreamRequest,
ClientStreamRequest,
ConformancePayload,
IdempotentUnaryRequest,
ServerStreamRequest,
UnaryRequest,
Expand All @@ -41,6 +42,8 @@ import { StreamType } from "./gen/connectrpc/conformance/v1/config_pb.js";

type ConformanceClient = PromiseClient<typeof ConformanceService>;

const emptyPayload = new ConformancePayload();

export function invokeWithPromiseClient(
transport: Transport,
compatRequest: ClientCompatRequest,
Expand Down Expand Up @@ -93,7 +96,7 @@ async function unary(
result.responseTrailers = convertToProtoHeaders(trailers);
},
});
result.payloads.push(response.payload!);
result.payloads.push(response.payload ?? emptyPayload);
} catch (e) {
setClientErrorResult(result, e);
}
Expand Down Expand Up @@ -125,7 +128,7 @@ async function serverStream(
controller.abort();
}
for await (const msg of res) {
result.payloads.push(msg.payload!);
result.payloads.push(msg.payload ?? emptyPayload);
if (result.payloads.length === cancelTiming.afterNumResponses) {
controller.abort();
}
Expand Down Expand Up @@ -172,7 +175,7 @@ async function clientStream(
},
},
);
result.payloads.push(response.payload!);
result.payloads.push(response.payload ?? emptyPayload);
} catch (e) {
setClientErrorResult(result, e);
}
Expand Down Expand Up @@ -210,7 +213,7 @@ async function bidiStream(
if (next.done === true) {
continue;
}
result.payloads.push(next.value.payload!);
result.payloads.push(next.value.payload ?? emptyPayload);
if (result.payloads.length === cancelTiming.afterNumResponses) {
controller.abort();
}
Expand All @@ -234,7 +237,7 @@ async function bidiStream(
if (next.done === true) {
break;
}
result.payloads.push(next.value.payload!);
result.payloads.push(next.value.payload ?? emptyPayload);
if (result.payloads.length === cancelTiming.afterNumResponses) {
controller.abort();
}
Expand Down
8 changes: 4 additions & 4 deletions packages/connect-web-bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ usually do. We repeat this for an increasing number of RPCs.

| code generator | RPCs | bundle size | minified | compressed |
| -------------- | ---: | ----------: | --------: | ---------: |
| Connect-ES | 1 | 152,759 b | 66,533 b | 16,438 b |
| Connect-ES | 4 | 168,201 b | 72,473 b | 16,896 b |
| Connect-ES | 8 | 193,514 b | 82,198 b | 17,477 b |
| Connect-ES | 16 | 227,153 b | 96,461 b | 18,226 b |
| Connect-ES | 1 | 152,703 b | 66,494 b | 16,400 b |
| Connect-ES | 4 | 168,145 b | 72,434 b | 16,865 b |
| Connect-ES | 8 | 193,458 b | 82,159 b | 17,484 b |
| Connect-ES | 16 | 227,097 b | 96,422 b | 18,224 b |
| gRPC-Web | 1 | 876,563 b | 548,495 b | 52,300 b |
| gRPC-Web | 4 | 928,964 b | 580,477 b | 54,673 b |
| gRPC-Web | 8 | 1,004,833 b | 628,223 b | 57,118 b |
Expand Down
10 changes: 5 additions & 5 deletions packages/connect-web-bench/chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions packages/connect/src/protocol-connect/error-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export function errorFromJson(
typeof detail != "object" ||
Array.isArray(detail) ||
typeof detail.type != "string" ||
typeof detail.value != "string" ||
("debug" in detail && typeof detail.debug != "object")
typeof detail.value != "string"
) {
throw fallback;
}
Expand Down

0 comments on commit 552d40b

Please sign in to comment.