Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/connect/src/implementation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,12 @@ describe("createHandlerContext()", function () {
expect(ctx.signal.aborted).toBeTrue();
expect(ctx.signal.reason).toBe("shutdown-signal");
});
it("should trigger on abort with reason", function () {
it("should trigger on abort", function () {
const ctx = createHandlerContext({ ...standardOptions });
ctx.abort("test-reason");
expect(ctx.signal.aborted).toBeTrue();
expect(ctx.signal.reason).toBe("test-reason");
});
it("should not trigger on abort without reason", function () {
const ctx = createHandlerContext({ ...standardOptions });
ctx.abort();
expect(ctx.signal.aborted).toBeFalse();
});
});

describe("timeout()", function () {
Expand Down
9 changes: 4 additions & 5 deletions packages/connect/src/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ export interface HandlerContext {
readonly service: DescService;

/**
* An AbortSignal that triggers when the deadline is reached, or when an
* error occurs that aborts processing of the request.
* An AbortSignal that triggers when the deadline is reached, or when an error
* occurs that aborts processing of the request, but also when the RPC is
* completed without error.
*
* The signal can be used to automatically cancel downstream calls.
*/
Expand Down Expand Up @@ -175,9 +176,7 @@ export function createHandlerContext(
responseTrailer: new Headers(init.responseTrailer),
abort(reason?: unknown) {
deadline.cleanup();
if (reason !== undefined) {
abortController.abort(reason);
}
abortController.abort(reason);
},
values: init.contextValues ?? createContextValues(),
};
Expand Down