Skip to content

Commit

Permalink
fix: handle empty resp from warmed up func
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Feb 12, 2018
1 parent 0668234 commit 18e7018
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lambda-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,15 @@ export default class LambdaUtils {
const fnResults = await Promise.all(new Array(concurrency).fill(0).map(async () => {
try {
const resp = await this.invoke(opts)
const body = resp.headers && resp.body && resp.isBase64Encoded
? JSON.parse(new Buffer(resp.body, 'base64').toString())
if (!resp) {
return {
error: 'received empty response'
}
}

let { headers, body, isBase64Encoded } = resp
body = headers && body && isBase64Encoded
? JSON.parse(new Buffer(body, 'base64').toString())
: resp

this.logger.info(`Warm Up Invoke Success: ${functionName}`, body)
Expand Down

0 comments on commit 18e7018

Please sign in to comment.