[@types/aws-lambda]: Streaming response types are not strictly accurate #73792
Unanswered
svozza
asked this question in
Issues with a @types package
Replies: 1 comment
-
|
Thanks for the discussion about "aws-lambda", some useful links for everyone: Pinging the DT module owners: @darbio, @skarum, @StefH, @buggy, @wwwy3y3, @OrthoDex, @MichaelMarner, @daniel-cottone, @kostya-misura, @coderbyheart, @palmithor, @daniloraisi, @simonbuchan, @Haydabase, @repl-chris, @aneilbaboo, @jeznag, @louislarry, @dpapukchiev, @ohookins, @trevor-leach, @jagregory, @dalen, @loikg, @skyzenr, @redlickigrzegorz, @juancarbonel, @pwmcintyre, @alex-bolenok-centralreach, @marianzange, @apalumbo, @SachinShekhar, @ivanmartos, @zach-anthony, @savnik, @bboure, @jamesorlakin, @aphex, @joeykilpatrick, @lmanerich, @LucianoTaranto. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using the HTTP streaming functionality in AWS Lambda function URLs, they are typed like so when using the
aws-lambdatypes:The
HttpResponseStreamtype used for theresponseStreamvariable is defined as extending theWritableclass:However, in the real Lambda runtime, it is just a class that has a single
frommethod as can be seen from the implementation here:Furthermore, there is a mismatch in the types the static
frommethod takes in the real runtime: it requires that the stream object passed in as the first parameter has asetContentTypemethod. The type defined in theawslambdaruntime will accept anyWriteableas the first parameter, which could result in a runtime error. In practice, this is very unlikely because almost always users will just be passing in theresponseStreamparameter from thestreamifyResponsedecorator and it will always have this method..The actual response stream type that is used by the lambda runtime is created with the following factory function: https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/962ed28eefbc052389c4de4366b1c0c49ee08a13/src/ResponseStream.js#L123. This ultimate results in a
Writable-like object with some custom fields likesetContentTypeand_onBeforeFirstWrite.A more accurate representation of the types would be something like this:
Beta Was this translation helpful? Give feedback.
All reactions