Skip to content

Commit 6cf822b

Browse files
committed
fix: catch error on getPegStatus to show it, and not load eternally
1 parent 3b5d25b commit 6cf822b

File tree

9 files changed

+25
-3
lines changed

9 files changed

+25
-3
lines changed

.github/workflows/deploy_MainNet_UI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
VUE_APP_RECAPTCHA_NEW_TOKEN_TIME=30
5858
VUE_APP_FLYOVER_PROVIDER_ID=2
5959
VUE_APP_CSP=https://lps.tekscapital.com
60+
VUE_APP_API_RESPONSE_TIMEOUT=10000
6061
npm run-script build
6162
6263
- name: Configure AWS credentials

.github/workflows/deploy_TestNet_UI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
VUE_APP_RECAPTCHA_NEW_TOKEN_TIME=30
5858
VUE_APP_FLYOVER_PROVIDER_ID=2
5959
VUE_APP_CSP=https://staging.lps.tekscapital.com
60+
VUE_APP_API_RESPONSE_TIMEOUT=10000
6061
npm run-script build
6162
6263
- name: Configure AWS credentials

.github/workflows/deploy_staging_MainNet_UI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
VUE_APP_RECAPTCHA_NEW_TOKEN_TIME=30
5858
VUE_APP_FLYOVER_PROVIDER_ID=2
5959
VUE_APP_CSP=https://lps.tekscapital.com
60+
VUE_APP_API_RESPONSE_TIMEOUT=10000
6061
npm run-script build
6162
6263
- name: Configure AWS credentials

.github/workflows/deploy_staging_TestNet_UI.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
VUE_APP_RECAPTCHA_NEW_TOKEN_TIME=30
5858
VUE_APP_FLYOVER_PROVIDER_ID=2
5959
VUE_APP_CSP=https://staging.lps.tekscapital.com
60+
VUE_APP_API_RESPONSE_TIMEOUT=10000
6061
npm run-script build
6162
6263
- name: Configure AWS credentials

ENV_VARIABLES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ The value of these variables are used in **environment-variables.ts** file.
2424
|VUE_APP_FLYOVER_PEGOUT_QUOTE_DIFF_PERCENTAGE | `2` | Defines quote difference percentage to 2% so it requieres the user to review condition only for a difference bigger that this percentage |
2525
|VUE_APP_RECAPTCHA_NEW_TOKEN_TIME | `30` | Specifies the time (in seconds) to temporarily disable the flyover between new transactions. This accounts for the time required by Google reCAPTCHA to regenerate a challenge token |
2626
|VUE_APP_FLYOVER_PROVIDER_ID | `1` | Sets up the provider id to be use for flyover status search. |
27+
|VUE_APP_FLYOVER_GET_PROVIDERS_TIMEOUT | `5000` | Sets a timeout for calls made to get liquidity providers. |
28+
|VUE_APP_API_RESPONSE_TIMEOUT | `10000` | Sets a timeout for calls made to API on search transaction. |
2729

2830
## Example for .env.local.test file
2931

@@ -46,4 +48,6 @@ VUE_APP_MIN_FEE_SAT_PER_BYTE_SLOW=1
4648
VUE_APP_LBC_ADDRESS='0xc2A630c053D12D63d32b025082f6Ba268db18300'
4749
VUE_APP_DEBUG_MODE='false'
4850
VUE_APP_FLYOVER_PEGOUT_QUOTE_DIFF_PERCENTAGE=2
51+
VUE_APP_API_RESPONSE_TIMEOUT=10000
52+
VUE_APP_FLYOVER_GET_PROVIDERS_TIMEOUT=5000
4953
```

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
@@ -225,6 +225,9 @@ export default defineComponent({
225225
setTxStatus(txId.value)
226226
.then(() => {
227227
loading.value = false;
228+
})
229+
.catch(() => {
230+
loading.value = false;
228231
});
229232
}
230233
}

0 commit comments

Comments
 (0)