@@ -78,15 +78,30 @@ export function DataProvider({ children }) {
7878 signal : controller . signal ,
7979 } ) ;
8080 clearTimeout ( id ) ;
81+ // If successful, resolve immediately
82+ if ( response . ok ) {
83+ resolve ( response . json ( ) ) ;
84+ return ; // Exit the loop and promise
85+ }
8186 } catch ( e ) {
82- console . log ( e ) ;
83- reject ( e ) ;
87+ console . log ( "Get rejection" , e ) ;
88+ // Only reject if there are no more retries
89+ if ( retries === 0 ) {
90+ reject ( e ) ;
91+ }
8492 }
8593 retries -- ;
94+ if ( retries > 0 ) {
95+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) ) ; // Wait 1 second
96+ }
97+ }
98+ // If the loop completes without a successful response, reject
99+ if ( ! ( response && response . ok ) ) {
100+ reject ( new Error ( "Failed to fetch data after multiple retries" ) ) ;
86101 }
87- resolve ( response . json ( ) ) ;
88102 } ) ;
89103 } ;
104+
90105 const parse = ( allFiles ) => {
91106 return retryablePostData ( {
92107 url : process . env . REACT_APP_API_PARSE ,
@@ -120,14 +135,14 @@ export function DataProvider({ children }) {
120135 const getVersion = useCallback ( ( ) => {
121136 return retryableGetData ( {
122137 url : process . env . REACT_APP_API_VERSION ,
123- timeout : 1500 ,
138+ timeout : 2500 ,
124139 } ) . then ( ( data ) => data . harmony_version || "unknown" ) ;
125140 } , [ ] ) ;
126141
127142 const getModels = useCallback ( ( ) => {
128143 return retryableGetData ( {
129144 url : process . env . REACT_APP_API_MODELS ,
130- timeout : 1500 ,
145+ timeout : 2500 ,
131146 } ) ;
132147 } , [ ] ) ;
133148
0 commit comments