Skip to content

Commit

Permalink
Check for Abort on web transports
Browse files Browse the repository at this point in the history
Signed-off-by: Sri Krishna Paritala <[email protected]>
  • Loading branch information
srikrsna-buf committed Sep 4, 2024
1 parent 04287b5 commit c0ba922
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
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,787 b | 66,535 b | 16,405 b |
| Connect-ES | 4 | 168,229 b | 72,475 b | 16,861 b |
| Connect-ES | 8 | 193,542 b | 82,200 b | 17,497 b |
| Connect-ES | 16 | 227,181 b | 96,463 b | 18,226 b |
| Connect-ES | 1 | 152,781 b | 66,543 b | 16,402 b |
| Connect-ES | 4 | 168,223 b | 72,483 b | 16,877 b |
| Connect-ES | 8 | 193,536 b | 82,208 b | 17,489 b |
| Connect-ES | 16 | 227,175 b | 96,471 b | 18,238 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.
6 changes: 3 additions & 3 deletions packages/connect-web/src/connect-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,10 @@ export function createConnectTransport(
}
yield parse(data);
}
if (signal.aborted) {
throw new ConnectError(`${signal.reason}`, Code.Canceled);
}
if (!endStreamReceived) {
if (signal.aborted) {
throw new ConnectError(`${signal.reason}`, Code.Canceled);
}
throw "missing EndStreamResponse";
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/connect-web/src/grpc-web-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export function createGrpcWebTransport(
trailerTarget: Headers,
header: Headers,
headerError: ConnectError | undefined,
signal: AbortSignal,
) {
const reader = createEnvelopeReadableStream(body).getReader();
if (foundStatus) {
Expand Down Expand Up @@ -314,6 +315,9 @@ export function createGrpcWebTransport(
yield parse(data);
continue;
}
if (signal.aborted) {
throw new ConnectError(`${signal.reason}`, Code.Canceled);
}
if (!trailerReceived) {
if (headerError) {
throw headerError;
Expand Down Expand Up @@ -388,6 +392,7 @@ export function createGrpcWebTransport(
trailer,
fRes.headers,
headerError,
req.signal,
),
};
return res;
Expand Down

0 comments on commit c0ba922

Please sign in to comment.