fix(simplefin): add 30s AbortSignal timeout to fetch calls
This commit is contained in:
parent
6168a71d8f
commit
a66fe13bc6
|
|
@ -64,7 +64,7 @@ async function claimSetupToken(setupToken) {
|
||||||
|
|
||||||
let accessUrl;
|
let accessUrl;
|
||||||
try {
|
try {
|
||||||
const res = await fetch(claimUrl, { method: 'POST' });
|
const res = await fetch(claimUrl, { method: 'POST', signal: AbortSignal.timeout(30000) });
|
||||||
if (res.status === 403) {
|
if (res.status === 403) {
|
||||||
throw new Error('This setup token has already been claimed or is invalid');
|
throw new Error('This setup token has already been claimed or is invalid');
|
||||||
}
|
}
|
||||||
|
|
@ -99,6 +99,7 @@ async function fetchAccountsAndTransactions(accessUrl, sinceEpoch) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(endpoint, {
|
const res = await fetch(endpoint, {
|
||||||
headers: { 'Authorization': `Basic ${basicAuth}` },
|
headers: { 'Authorization': `Basic ${basicAuth}` },
|
||||||
|
signal: AbortSignal.timeout(30000),
|
||||||
});
|
});
|
||||||
if (res.status === 403) {
|
if (res.status === 403) {
|
||||||
throw Object.assign(new Error('SimpleFIN access has been revoked — please reconnect'), { code: 'SIMPLEFIN_REVOKED' });
|
throw Object.assign(new Error('SimpleFIN access has been revoked — please reconnect'), { code: 'SIMPLEFIN_REVOKED' });
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue