Skip to content

Commit 7bddac1

Browse files
committed
fix: catch error on getPegStatus to show it, and not load eternally
1 parent 0991820 commit 7bddac1

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/common/types/environment-variables.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export class EnvironmentVariables {
4444

4545
public cspConfiguration: string;
4646

47+
public apiResponseTimeout: number;
48+
4749
public minFeeSatPerByte: {
4850
fast: number;
4951
average: number;
@@ -107,6 +109,8 @@ export class EnvironmentVariables {
107109
this.flyoverProviderId = Number(process.env.VUE_APP_FLYOVER_PROVIDER_ID)
108110
|| defaultValues.flyoverProviderId;
109111
this.cspConfiguration = process.env.VUE_APP_CSP || defaultValues.cspConfiguration;
112+
this.apiResponseTimeout = Number(process.env.VUE_APP_API_RESPONSE_TIMEOUT)
113+
|| defaultValues.apiResponseTimeout;
110114
}
111115

112116
public get chainId(): number {

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const defaultEnvironmentVariables = {
3535
flyoverProviderId: 2,
3636
grecaptchaTime: constants.RECAPTCHA_NEW_TOKEN_TIME,
3737
cspConfiguration: 'https://testnet.lps.tekscapital.com https://staging.lps.tekscapital.com',
38+
apiResponseTimeout: 5000,
3839
};
3940

4041
EnvironmentAccessorService.initializeEnvironmentVariables(defaultEnvironmentVariables);

src/status/store/actions.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { EnvironmentAccessorService } from '@/common/services/enviroment-accesso
1010
import * as constants from '@/common/store/constants';
1111
import { ApiService } from '@/common/services';
1212
import { BridgeService } from '@/common/services/BridgeService';
13-
import { getEstimatedFee } from '@/common/utils';
13+
import { getEstimatedFee, promiseWithTimeout } from '@/common/utils';
1414

1515
export const actions: ActionTree<TxStatus, RootState> = {
1616
[constants.STATUS_CLEAR]: ({ commit }) => {
@@ -19,8 +19,14 @@ export const actions: ActionTree<TxStatus, RootState> = {
1919
[constants.STATUS_GET_TX_STATUS]:
2020
({ commit, dispatch }, txId: string) => new Promise((resolve, reject) => {
2121
Promise.all([
22-
ApiService.getTxStatus(txId),
23-
dispatch(constants.STATUS_GET_ESTIMATED_FEE),
22+
promiseWithTimeout(
23+
ApiService.getTxStatus(txId),
24+
EnvironmentAccessorService.getEnvironmentVariables().apiResponseTimeout,
25+
),
26+
promiseWithTimeout(
27+
dispatch(constants.STATUS_GET_ESTIMATED_FEE),
28+
EnvironmentAccessorService.getEnvironmentVariables().apiResponseTimeout,
29+
),
2430
])
2531
.then(([status]) => {
2632
commit(constants.STATUS_SET_TX_DETAILS, status.txDetails);

src/status/views/Status.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ export default defineComponent({
219219
setTxStatus(txId.value)
220220
.then(() => {
221221
loading.value = false;
222+
})
223+
.catch(() => {
224+
loading.value = false;
222225
});
223226
}
224227
}

0 commit comments

Comments
 (0)