Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sk/rst_noerror
Browse files Browse the repository at this point in the history
Signed-off-by: Sri Krishna Paritala <skrishna@buf.build>
  • Loading branch information
srikrsna-buf committed Sep 11, 2024
2 parents bda04bf + 552d40b commit 3822649
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,762 b | 66,522 b | 16,383 b |
| Connect-ES | 4 | 168,204 b | 72,461 b | 16,895 b |
| Connect-ES | 8 | 193,517 b | 82,184 b | 17,500 b |
| Connect-ES | 16 | 227,156 b | 96,450 b | 18,264 b |
| Connect-ES | 1 | 152,706 b | 66,483 b | 16,386 b |
| Connect-ES | 4 | 168,148 b | 72,422 b | 16,890 b |
| Connect-ES | 8 | 193,461 b | 82,145 b | 17,461 b |
| Connect-ES | 16 | 227,100 b | 96,411 b | 18,214 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 3822649

Please sign in to comment.