Skip to content

Commit d93a622

Browse files
authored
Revert "SAM run/debug: do not stringify the error from got" #2265
After #2263, - even valid paths are rejected too quickly (no pause between retries). - 403 is being handled by `got` in unexpected ways, e.g. it doesn't respect the retry limit?
1 parent 1bf21f3 commit d93a622

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/shared/sam/localLambdaRunner.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,12 @@ async function requestLocalApi(
475475
methods: [reqMethod],
476476
calculateDelay: obj => {
477477
if (obj.error.response !== undefined) {
478-
getLogger().debug('Local API response: %s : %O', uri, obj.error.response.statusMessage)
478+
getLogger().debug('Local API response: %s : %O', uri, JSON.stringify(obj.error.response))
479479
}
480-
if (obj.error.code === 'ETIMEDOUT' || obj.error.code === 'ECONNREFUSED') {
480+
if (obj.error.code === 'ETIMEDOUT') {
481481
return 0
482482
}
483-
getLogger().debug(
484-
`Local API: retry (${obj.attemptCount} of ${RETRY_LIMIT}): ${uri}: ${obj.error.message}`
485-
)
483+
getLogger().debug(`Local API: retry (${obj.attemptCount} of ${RETRY_LIMIT}): ${uri}: ${obj.error}`)
486484
return RETRY_DELAY
487485
},
488486
},
@@ -498,7 +496,7 @@ async function requestLocalApi(
498496
getLogger().info('Local API is alive: %s', uri)
499497
return
500498
}
501-
const msg = `Local API failed to respond (${err.code}) after ${RETRY_LIMIT} retries, path: ${api?.path}, error: ${err.message}`
499+
const msg = `Local API failed to respond (${err.code}) after ${RETRY_LIMIT} retries, path: ${api?.path}, error: ${err}`
502500
getLogger('channel').error(msg)
503501
throw new Error(msg)
504502
})

0 commit comments

Comments
 (0)