Log SDK timeout errors

Logging it so we know when to give the SDKs a kick
This commit is contained in:
infinite-persistence 2022-05-05 13:07:04 +08:00 committed by Thomas Zarebczan
parent 511097cd67
commit d7d8d3516e
2 changed files with 5 additions and 1 deletions

View file

@ -1,4 +1,5 @@
// @flow // @flow
import analytics from 'analytics';
import { FETCH_TIMEOUT } from 'constants/errors'; import { FETCH_TIMEOUT } from 'constants/errors';
import { NO_AUTH, X_LBRY_AUTH_TOKEN } from 'constants/token'; import { NO_AUTH, X_LBRY_AUTH_TOKEN } from 'constants/token';
import fetchWithTimeout from 'util/fetch'; import fetchWithTimeout from 'util/fetch';
@ -320,7 +321,8 @@ export function apiCall(method: string, params: ?{}, resolve: Function, reject:
}) })
.catch((err) => { .catch((err) => {
ApiFailureMgr.logFailure(method, params, counter); ApiFailureMgr.logFailure(method, params, counter);
if (err?.message === FETCH_TIMEOUT) { if (err?.message === FETCH_TIMEOUT) {
analytics.error(`${method}: timed out after ${SDK_FETCH_TIMEOUT_MS / 1000}s`);
reject(resolveFetchErrorMsg(method, FETCH_TIMEOUT)); reject(resolveFetchErrorMsg(method, FETCH_TIMEOUT));
} else { } else {
reject(err); reject(err);

View file

@ -5,6 +5,7 @@
// - 'file' binary // - 'file' binary
// - 'json_payload' publish params to be passed to the server's sdk. // - 'json_payload' publish params to be passed to the server's sdk.
import analytics from '../../ui/analytics';
import { PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL } from '../../ui/constants/errors'; import { PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL } from '../../ui/constants/errors';
import { X_LBRY_AUTH_TOKEN } from '../../ui/constants/token'; import { X_LBRY_AUTH_TOKEN } from '../../ui/constants/token';
import { doUpdateUploadAdd, doUpdateUploadProgress, doUpdateUploadRemove } from '../../ui/redux/actions/publish'; import { doUpdateUploadAdd, doUpdateUploadProgress, doUpdateUploadRemove } from '../../ui/redux/actions/publish';
@ -64,6 +65,7 @@ export function makeUploadRequest(
reject(new Error(__('There was a problem with your upload. Please try again.'))); reject(new Error(__('There was a problem with your upload. Please try again.')));
}; };
xhr.ontimeout = () => { xhr.ontimeout = () => {
analytics.error(`publish-v1: timed out after ${PUBLISH_FETCH_TIMEOUT_MS / 1000}s`);
window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' })); window.store.dispatch(doUpdateUploadProgress({ guid, status: 'error' }));
reject(new Error(PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL)); reject(new Error(PUBLISH_TIMEOUT_BUT_LIKELY_SUCCESSFUL));
}; };