Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid the AbortController constructor during init #554

Merged
merged 1 commit into from
Mar 31, 2023
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
2 changes: 1 addition & 1 deletion packages/connect/src/protocol/universal-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("validateUniversalHandlerOptions()", function () {
jsonOptions: undefined,
binaryOptions: undefined,
maxDeadlineDurationMs: Number.MAX_SAFE_INTEGER,
shutdownSignal: new AbortController().signal,
shutdownSignal: undefined,
requireConnectProtocolHeader: false,
});
});
Expand Down
7 changes: 2 additions & 5 deletions packages/connect/src/protocol/universal-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface UniversalHandlerOptions {
binaryOptions?: Partial<BinaryReadOptions & BinaryWriteOptions>;

maxDeadlineDurationMs: number; // TODO TCN-785
shutdownSignal: AbortSignal; // TODO TCN-919
shutdownSignal?: AbortSignal; // TODO TCN-919

/**
* Require requests using the Connect protocol to include the header
Expand Down Expand Up @@ -139,8 +139,6 @@ export interface UniversalHandler extends UniversalHandlerFn {
supportedContentType: ContentTypeMatcher;
}

const neverSignal = new AbortController().signal;

/**
* Asserts that the options are within sane limits, and returns default values
* where no value is provided.
Expand All @@ -156,7 +154,6 @@ export function validateUniversalHandlerOptions(
: [];
const requireConnectProtocolHeader =
opt.requireConnectProtocolHeader ?? false;
const shutdownSignal = opt.shutdownSignal ?? neverSignal;
const maxDeadlineDurationMs =
opt.maxDeadlineDurationMs ?? Number.MAX_SAFE_INTEGER;
return {
Expand All @@ -169,7 +166,7 @@ export function validateUniversalHandlerOptions(
jsonOptions: opt.jsonOptions,
binaryOptions: opt.binaryOptions,
maxDeadlineDurationMs,
shutdownSignal,
shutdownSignal: opt.shutdownSignal,
requireConnectProtocolHeader,
};
}
Expand Down