Skip to content

Commit b4ffa0d

Browse files
committed
respect payloadAsStream also in error case
1 parent 275d0ff commit b4ffa0d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

index.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,19 @@ module.exports = (app, options) => {
115115
currentAwsArguments = {}
116116
if (err) {
117117
console.error(err)
118+
if (!options.payloadAsStream) {
119+
return resolve({
120+
statusCode: 500,
121+
body: '',
122+
headers: {}
123+
})
124+
}
118125
return resolve({
119-
statusCode: 500,
120-
body: '',
121-
headers: {}
126+
meta: {
127+
statusCode: 500,
128+
headers: {}
129+
},
130+
stream: (res && res.stream()) || require('node:stream').Readable.from('')
122131
})
123132
}
124133
// chunked transfer not currently supported by API Gateway

0 commit comments

Comments
 (0)