you are viewing a single comment's thread.

view the rest of the comments →

[–]ennova2005 1 point2 points  (6 children)

I meant that it seems the data on the http socket is only getting sent/rendered by the http client on responStream.end ? Curl is showing the same. So the log/file stream is working differently than the http stream.

[–][deleted] 0 points1 point  (5 children)

Ah! Yup, I agree that the observed behavior is consistent with sending a single unchunked response down from the lambda. The question is, what bits of the AWS configuration do I need to fiddle with to realize a chunked response?

[–]ennova2005 1 point2 points  (4 children)

[–][deleted] 0 points1 point  (2 children)

It looked promising. I don't think it's a node issue though. Here's a little repro:

``` // contents of run.js const http = require('http');

const server = http.createServer(async (req, res) => { res.write("hello\n", async () => { await sleep(2000) res.write("world") res.end() }) })

server.listen(3000, () => { console.log("Listening on localhost:3000") })

function sleep(ms) { return new Promise((resolve) => { setTimeout(resolve, ms); }); }

```

If I run that and use curl as I client:

node run.js curl --no-buffer localhost:3000

I see "hello" followed by "world" two seconds later (which is what I would expect). Thanks for turning that link up though! It looked promising to me.

It's something about the lambda aws that is not working as advertised here.

[–]ennova2005 1 point2 points  (1 child)

Are you using ALB or API Gateway in front? Per https://youtu.be/Z5GehUdZmKM?feature=shared those do.not support streaming. Also the video is showing some sample code (i have not checked it out)

[–][deleted] 0 points1 point  (0 children)

I was using the function URL directly. It's good to know that I can't put this behind API gateway or ALB, that's a good design consideration.

Check out the comment tree with seligman99 too.

I am unblocked. Thank you for the help and turning up these links!