Skip to content

Commit

Permalink
Fix gRPC-Web trailers-only response handling for server-streaming RPCs (
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Oct 9, 2024
1 parent 9ad3b81 commit 615a175
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/connect-web/src/grpc-web-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ export function createGrpcWebTransport(
foundStatus: boolean,
trailerTarget: Headers,
header: Headers,
headerError: ConnectError | undefined,
signal: AbortSignal,
) {
const reader = createEnvelopeReadableStream(body).getReader();
Expand Down Expand Up @@ -313,7 +312,6 @@ export function createGrpcWebTransport(
throw "extra message";
}
yield parse(data);
continue;
}
// Node wil not throw an AbortError on `read` if the
// signal is aborted before `getReader` is called.
Expand All @@ -326,9 +324,6 @@ export function createGrpcWebTransport(
signal.throwIfAborted();
}
if (!trailerReceived) {
if (headerError) {
throw headerError;
}
throw "missing trailer";
}
}
Expand Down Expand Up @@ -382,10 +377,10 @@ export function createGrpcWebTransport(
fRes.status,
fRes.headers,
);
if (headerError != undefined) {
throw headerError;
}
if (!fRes.body) {
if (headerError != undefined) {
throw headerError;
}
throw "missing response body";
}
const trailer = new Headers();
Expand All @@ -398,7 +393,6 @@ export function createGrpcWebTransport(
foundStatus,
trailer,
fRes.headers,
headerError,
req.signal,
),
};
Expand Down

0 comments on commit 615a175

Please sign in to comment.