Set 5s as default timeout for ping (#6271)

This commit is contained in:
Elias Nahum
2022-05-13 11:36:30 -04:00
committed by GitHub
parent e81e98aa02
commit 2c6bd00128
4 changed files with 11 additions and 5 deletions

View File

@@ -244,6 +244,10 @@ export default class ClientBase {
retryLimit: 0,
};
}
if (options.timeoutInterval) {
requestOptions.timeoutInterval = options.timeoutInterval;
}
let response: ClientResponse;
try {
response = await request!(url, requestOptions);

View File

@@ -7,7 +7,7 @@ import ClientError from './error';
export interface ClientGeneralMix {
getOpenGraphMetadata: (url: string) => Promise<any>;
ping: (deviceId?: string) => Promise<any>;
ping: (deviceId?: string, timeoutInterval?: number) => Promise<any>;
logClientError: (message: string, level?: string) => Promise<any>;
getClientConfigOld: () => Promise<ClientConfig>;
getClientLicenseOld: () => Promise<ClientLicense>;
@@ -25,14 +25,14 @@ const ClientGeneral = (superclass: any) => class extends superclass {
);
};
ping = async (deviceId?: string) => {
ping = async (deviceId?: string, timeoutInterval?: number) => {
let url = `${this.urlVersion}/system/ping?time=${Date.now()}`;
if (deviceId) {
url = `${url}&device_id=${deviceId}`;
}
return this.doFetch(
url,
{method: 'get'},
{method: 'get', timeoutInterval},
false,
);
};