Skip to content

Commit

Permalink
fix: Added timeout functionality to website connector to prevent bloc…
Browse files Browse the repository at this point in the history
…king
  • Loading branch information
Thomas Nairn authored and Thomas Nairn committed Jul 2, 2021
1 parent c95eaee commit 62bfe04
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/connectors/website/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface SiteConfig {
export interface WebsiteConnectionConfig {
id?: string;
interval?: number;
timeout?: number;
sites: SiteConfig[];
}

Expand All @@ -52,6 +53,7 @@ export const websiteConnection = (
id = CONNECTOR_TYPE,
sites = [],
interval = 30000,
timeout = 30000,
}: WebsiteConnectionConfig,
logger: Logger
) => {
Expand Down Expand Up @@ -81,7 +83,7 @@ export const websiteConnection = (
tap({
complete: () => logger.verbose("complete"),
}),
switchMap((i) => {
exhaustMap((i) => {
return of(i).pipe(
exhaustMap(() => {
logger.verbose("createRequest");
Expand All @@ -99,9 +101,11 @@ export const websiteConnection = (
if (typeof request === "string")
return Axios.get(request, {
validateStatus,
timeout,
responseType: "text",
});
return Axios.request({
timeout,
...request,
validateStatus,
responseType: "text",
Expand Down

0 comments on commit 62bfe04

Please sign in to comment.