Skip to content

Commit d507885

Browse files
committed
just to be sure check if res and stream are available
1 parent a5a0aaa commit d507885

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ module.exports = (app, options) => {
122122
headers: {}
123123
})
124124
}
125-
const stream = res.stream()
125+
const stream = res && res.stream()
126126
return resolve({
127127
meta: {
128128
statusCode: 500,
129129
headers: {}
130130
},
131131
// fix issue with Lambda where streaming repsonses always require a body to be present
132-
stream: stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
132+
stream: stream && stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
133133
})
134134
}
135135
// chunked transfer not currently supported by API Gateway
@@ -177,7 +177,7 @@ module.exports = (app, options) => {
177177
resolve({
178178
meta: ret,
179179
// fix issue with Lambda where streaming repsonses always require a body to be present
180-
stream: stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
180+
stream: stream && stream.readableLength > 0 ? stream : require('node:stream').Readable.from('')
181181
})
182182
})
183183
})

0 commit comments

Comments
 (0)