Skip to content

Commit

Permalink
Call cleanup every time instead of abort
Browse files Browse the repository at this point in the history
  • Loading branch information
lourd committed Jun 26, 2024
1 parent 1d71dc9 commit 2e32fb8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/connect/src/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ interface HandlerContextInit {
}

interface HandlerContextController extends HandlerContext {
cleanup(): void;
abort(reason?: unknown): void;
}

Expand Down Expand Up @@ -183,6 +184,7 @@ export function createHandlerContext(
requestHeader: new Headers(init.requestHeader),
responseHeader: new Headers(init.responseHeader),
responseTrailer: new Headers(init.responseTrailer),
cleanup: deadline.cleanup,
abort(reason?: unknown) {
deadline.cleanup();
abortController.abort(reason);
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/protocol-connect/handler-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function createUnaryHandler<I extends Message<I>, O extends Message<O>>(
});
body = errorToJsonBytes(error, opt.jsonOptions);
} finally {
context.abort();
context.cleanup();
}
if (compression.response && body.byteLength >= opt.compressMinBytes) {
body = await compression.response.compress(body);
Expand Down

0 comments on commit 2e32fb8

Please sign in to comment.