Skip to content

Commit

Permalink
Check for abort error
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 4, 2024
1 parent bb7d59c commit ebcbb53
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 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,643 b | 66,478 b | 16,380 b |
| Connect-ES | 4 | 168,085 b | 72,418 b | 16,852 b |
| Connect-ES | 8 | 193,398 b | 82,142 b | 17,475 b |
| Connect-ES | 16 | 227,037 b | 96,408 b | 18,237 b |
| 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 |
| 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.
11 changes: 10 additions & 1 deletion packages/connect-web/src/connect-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export function createConnectTransport(
body: ReadableStream<Uint8Array>,
trailerTarget: Headers,
header: Headers,
signal: AbortSignal,
) {
const reader = createEnvelopeReadableStream(body).getReader();
let endStreamReceived = false;
Expand Down Expand Up @@ -299,6 +300,9 @@ export function createConnectTransport(
yield parse(data);
}
if (!endStreamReceived) {
if (signal.aborted) {
throw new ConnectError(`${signal.reason}`, Code.Canceled);
}
throw "missing EndStreamResponse";
}
}
Expand Down Expand Up @@ -369,7 +373,12 @@ export function createConnectTransport(
...req,
header: fRes.headers,
trailer,
message: parseResponseBody(fRes.body, trailer, fRes.headers),
message: parseResponseBody(
fRes.body,
trailer,
fRes.headers,
req.signal,
),
};
return res;
},
Expand Down

0 comments on commit ebcbb53

Please sign in to comment.