66 generateRandomString ,
77 delay ,
88 instanceSizes ,
9+ fetchWithRetry ,
910} from './utils.js' ;
1011import { StatusLogger } from './StatusLogger.js' ;
1112
@@ -64,7 +65,7 @@ export async function invokeRemoteMachine(payload, options) {
6465 } ;
6566
6667 const { curCompilerURL} = await determineCompilerUrl ( options ) ;
67- const response = await fetch ( curCompilerURL , {
68+ const response = await fetchWithRetry ( curCompilerURL , {
6869 method : 'POST' ,
6970 headers : {
7071 'Content-Type' : 'application/json' ,
@@ -87,7 +88,7 @@ export async function invokeRemoteMachine(payload, options) {
8788 const { stderr, stdout} = await watchInstance ( options . config . blobUrl , requestId , apiKey , options , 8000 ) ;
8889 console . error ( stderr ) ;
8990 console . log ( stdout ) ;
90- const response = await fetch ( `${ options . config . blobUrl } instance-response/${ requestId } .json` ) ;
91+ const response = await fetchWithRetry ( `${ options . config . blobUrl } instance-response/${ requestId } .json` ) ;
9192 try {
9293 const data = await response . json ( ) ;
9394 body = JSON . parse ( data . body ) ;
@@ -103,7 +104,7 @@ export async function verifyCircuit(action, pkgName, chainId, contract, options)
103104 const event = { payload : { action, pkgName, chainId, contract} } ;
104105 console . log ( `# Verifying circuit...` ) ;
105106
106- const response = await fetch ( options . config . serverURL , {
107+ const response = await fetchWithRetry ( options . config . serverURL , {
107108 method : 'POST' ,
108109 headers : {
109110 'Content-Type' : 'application/json' ,
@@ -228,13 +229,13 @@ function healthcheckFetch(ip, timeout) {
228229 const timeoutPromise = new Promise ( ( _ , reject ) =>
229230 setTimeout ( ( ) => reject ( new TimeoutError ( ) ) , timeout )
230231 ) ;
231- const fetchPromise = fetch ( `http://${ ip } :3000` ) ;
232+ const fetchPromise = fetchWithRetry ( `http://${ ip } :3000` ) ;
232233 return Promise . race ( [ fetchPromise , timeoutPromise ] ) ;
233234}
234235
235236async function terminateInstance ( requestId , apiKey , options ) {
236237 const event = { payload : { requestId} , apiKey} ;
237- const response = await fetch ( process . env . LOCAL_TERMINATOR || ( options && options . config && options . config . terminatorURL ) , {
238+ const response = await fetchWithRetry ( process . env . LOCAL_TERMINATOR || ( options && options . config && options . config . terminatorURL ) , {
238239 method : 'POST' ,
239240 headers : {
240241 'Content-Type' : 'application/json' ,
@@ -250,7 +251,7 @@ async function terminateInstance(requestId, apiKey, options) {
250251}
251252
252253async function fetchResult ( blobUrl , requestId , pipename ) {
253- const response = await fetch ( `${ blobUrl } instance/${ requestId } /${ pipename } .txt` ) ;
254+ const response = await fetchWithRetry ( `${ blobUrl } instance/${ requestId } /${ pipename } .txt` ) ;
254255 if ( ! response . ok ) {
255256 if ( response . status === 404 || response . status === 403 ) {
256257 throw new NotFoundError ;
0 commit comments