catch gpa fail

This commit is contained in:
Nour Alharithi
2023-12-04 21:35:16 -08:00
parent 5996143a5a
commit c4059d3ca0
2 changed files with 28 additions and 9 deletions

View File

@@ -30,6 +30,7 @@ import {
getDLOBProviderFromOrderSubscriber,
getDLOBProviderFromUserMap,
} from '../dlobProvider';
import FEATURE_FLAGS from '../utils/featureFlags';
require('dotenv').config();
const stateCommitment: Commitment = 'processed';
@@ -229,10 +230,22 @@ const main = async () => {
spotMarketSubscribers: MARKET_SUBSCRIBERS,
});
await dlobSubscriber.subscribe();
if (useWebsocket) {
setInterval(async () => {
await dlobProvider.fetch();
}, WS_FALLBACK_FETCH_INTERVAL);
if (useWebsocket && !FEATURE_FLAGS.DISABLE_GPA_REFRESH) {
const recursiveFetch = (delay = WS_FALLBACK_FETCH_INTERVAL) => {
setTimeout(() => {
dlobProvider
.fetch()
.then(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
recursiveFetch();
})
.catch(() => {
logger.error('Failed to fetch GPA');
recursiveFetch();
});
}, delay);
};
recursiveFetch();
}
console.log('DLOBSubscriber Publishing Messages');