Skip to content

Commit

Permalink
Do use client-side timeout for import endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbosco committed Jul 6, 2023
1 parent a4d3330 commit 7342a6f
Show file tree
Hide file tree
Showing 10 changed files with 270 additions and 253 deletions.
473 changes: 240 additions & 233 deletions dist/typesense.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/typesense.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/typesense.min.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/Typesense/ApiCall.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ export default class ApiCall {
post<T>(endpoint: string, bodyParameters?: any, queryParameters?: any, additionalHeaders?: any): Promise<T>;
put<T>(endpoint: string, bodyParameters?: any, queryParameters?: any): Promise<T>;
patch<T>(endpoint: string, bodyParameters?: any, queryParameters?: any): Promise<T>;
performRequest<T>(requestType: Method, endpoint: string, { queryParameters, bodyParameters, additionalHeaders, abortSignal, responseType, }: {
performRequest<T>(requestType: Method, endpoint: string, { queryParameters, bodyParameters, additionalHeaders, abortSignal, responseType, skipConnectionTimeout, }: {
queryParameters?: any;
bodyParameters?: any;
additionalHeaders?: any;
abortSignal?: any;
responseType?: AxiosRequestConfig["responseType"] | undefined;
skipConnectionTimeout?: boolean;
}): Promise<T>;
getNextNode(requestNumber?: number): Node;
nodeDueForHealthcheck(node: any, requestNumber?: number): boolean;
Expand Down
30 changes: 16 additions & 14 deletions lib/Typesense/ApiCall.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Typesense/ApiCall.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/Typesense/Documents.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Typesense/Documents.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/Typesense/ApiCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@ export default class ApiCall {
additionalHeaders = {},
abortSignal = null,
responseType = undefined,
skipConnectionTimeout = false,
}: {
queryParameters?: any;
bodyParameters?: any;
additionalHeaders?: any;
abortSignal?: any;
responseType?: AxiosRequestConfig["responseType"] | undefined;
skipConnectionTimeout?: boolean;
}
): Promise<T> {
this.configuration.validate();
Expand Down Expand Up @@ -168,7 +170,6 @@ export default class ApiCall {
additionalHeaders,
this.additionalUserHeaders
),
timeout: this.connectionTimeoutSeconds * 1000,
maxContentLength: Infinity,
maxBodyLength: Infinity,
responseType,
Expand All @@ -195,6 +196,10 @@ export default class ApiCall {
],
};

if (skipConnectionTimeout !== true) {
requestOptions.timeout = this.connectionTimeoutSeconds * 1000;
}

if (queryParameters && Object.keys(queryParameters).length !== 0) {
requestOptions.params = queryParameters;
}
Expand Down
1 change: 1 addition & 0 deletions src/Typesense/Documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export default class Documents<T extends DocumentSchema = object>
queryParameters: options,
bodyParameters: documentsInJSONLFormat,
additionalHeaders: { "Content-Type": "text/plain" },
skipConnectionTimeout: true, // We never want to client-side-timeout on an import and retry, since imports are syncronous and we want to let them take as long as it takes to complete fully
}
);

Expand Down

0 comments on commit 7342a6f

Please sign in to comment.