-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
The function makeRequest() in request.js ignores the pollForMs/pollDelayMs attribute, if the first connection attempt fails due to a network error (e.g. service not up yet). This is exactly the scenario the attribute(s) was/were introduced for in the first place though:
function makeRequest() {
return fetch( url, options )
.then( response => processResponse( item, response, options ), err => {
// Treat network errors as regular FAILURE (since e.g. the required host is not up)
const failures = [ `${err} (${method} ${url})` ];
return {
outcome: 'FAILURE',
failures
};
} )
.then( result => {
if( pollForMs > Date.now() - startMs && result.outcome !== 'SUCCESS' ) {
return delay( pollDelayMs ).then( makeRequest );
}
return result;
} );
}
With the following change the function works as expected:
function makeRequest() {
return fetch( url, options )
.then( response => processResponse( item, response, options ), err => {
if( pollForMs > Date.now() - startMs ) {
return delay( pollDelayMs ).then( makeRequest );
}
// Treat network errors as regular FAILURE (since e.g. the required host is not up)
const failures = [ `${err} (${method} ${url})` ];
return {
outcome: 'FAILURE',
failures
};
} )
.then( result => {
if( pollForMs > Date.now() - startMs && result.outcome !== 'SUCCESS' ) {
return delay( pollDelayMs ).then( makeRequest );
}
return result;
} );
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels