From d6490e0faa00be1e3a0657952a1ecd3f869d7c5c Mon Sep 17 00:00:00 2001 From: Rui Marinho Date: Sun, 31 Oct 2021 18:12:49 +0000 Subject: [PATCH] Abort context on route errors blocked by client --- index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4c87c1b..436c7ae 100755 --- a/index.js +++ b/index.js @@ -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());