Skip to content

Commit

Permalink
error handling for getNextTestInfo (upon 500 axios error), #219
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 30, 2024
1 parent dbcada5 commit 155f552
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions js/node-client/getNextTestInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ module.exports = async function( options ) {

}, options );

const response = await axios( `${options.serverURL}/aquaserver/next-test?old=${options.old}` );
let response = {};
try {
response = await axios( `${options.serverURL}/aquaserver/next-test?old=${options.old}` );
}
catch( e ) {
throw new Error( `axios failure code ${e.response.status} getting next-test: ${e.message}` );
}

if ( response.status !== 200 ) {
throw new Error( `nextTest request failed with status ${response.status} ${response}` );
}

return response.data;
return response.data || {};
};
8 changes: 5 additions & 3 deletions js/node-client/runNextTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@ const winston = require( 'winston' );
*/
module.exports = async function( options ) {

const testInfo = await getNextTestInfo( options );
winston.info( 'testInfo', JSON.stringify( testInfo ) );

const attemptCount = 3;
let attemptsLeft = attemptCount;

let lastFailure;

let testInfo = null;
while ( attemptsLeft-- > 0 ) {
try {
if ( !testInfo ) {
testInfo = await getNextTestInfo( options );
winston.info( 'testInfo', JSON.stringify( testInfo ) );
}
await runTest( testInfo, options );
winston.debug( 'runTest completed' );
return;
Expand Down

0 comments on commit 155f552

Please sign in to comment.