Skip to content

Commit

Permalink
Abort context on route errors blocked by client
Browse files Browse the repository at this point in the history
  • Loading branch information
ruimarinho committed Oct 31, 2021
1 parent bde055f commit d6490e0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,23 @@ async function formatOutput(awsSharedCredentialsFile, awsProfile, format = null)
}

logger.debug(`Aborting request to "${route.request().url()}"`);
route.abort();

// Abort with a specific error so we can tag these requests as being blocked by gsts
// instead of a configuration issue (like a custom ARN not being available).
route.abort('blockedbyclient');
});

page.on('requestfailed', async request => {
logger.debug(`Request to "${request.url()}" has failed`);

// Requests tagged with this specific error were made by gsts and should result
// in a program termination.
if (request.failure().errorText !== 'net::ERR_BLOCKED_BY_CLIENT') {
logger.debug(`Aborted due to client request`);
await context.close();
return;
}

// The request to the AWS console is aborted on successful login for performance reasons,
// so in this particular case it's actually an expected outcome.
const parsedURL = url.parse(request.url());
Expand Down

0 comments on commit d6490e0

Please sign in to comment.