Skip to content

Commit

Permalink
just to be sure check if res and stream are available
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Jan 27, 2025
1 parent a5a0aaa commit d507885
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ module.exports = (app, options) => {
headers: {}
})
}
const stream = res.stream()
const stream = res && res.stream()
return resolve({
meta: {
statusCode: 500,
headers: {}
},
// fix issue with Lambda where streaming repsonses always require a body to be present
stream: stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
stream: stream && stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
})
}
// chunked transfer not currently supported by API Gateway
Expand Down Expand Up @@ -177,7 +177,7 @@ module.exports = (app, options) => {
resolve({
meta: ret,
// fix issue with Lambda where streaming repsonses always require a body to be present
stream: stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
stream: stream && stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
})
})
})
Expand Down

0 comments on commit d507885

Please sign in to comment.