-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix issue with Lambda where streaming repsonses always require a body…
… to be present
- Loading branch information
Showing
1 changed file
with
6 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,12 +122,14 @@ module.exports = (app, options) => { | |
headers: {} | ||
}) | ||
} | ||
const stream = res.stream() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
adrai
Author
Member
|
||
return resolve({ | ||
meta: { | ||
statusCode: 500, | ||
headers: {} | ||
}, | ||
stream: (res && res.stream()) || require('node:stream').Readable.from('') | ||
// fix issue with Lambda where streaming repsonses always require a body to be present | ||
stream: stream.readableLength > 0 ? stream : require('node:stream').Readable.from('') | ||
}) | ||
} | ||
// chunked transfer not currently supported by API Gateway | ||
|
@@ -171,9 +173,11 @@ module.exports = (app, options) => { | |
return resolve(ret) | ||
} | ||
|
||
const stream = res.stream() | ||
resolve({ | ||
meta: ret, | ||
stream: res.stream() | ||
// fix issue with Lambda where streaming repsonses always require a body to be present | ||
stream: stream.readableLength > 0 ? stream : require('node:stream').Readable.from('') | ||
}) | ||
}) | ||
}) | ||
|
@adrai was the extra check to see if the response is available needed? the update removed that check, but I wasn't sure if that was intentional