-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only newlines send to clients. #260
Comments
I might have a PR ready soon. I needed to dig into it. My workaround was not quite sufficient. |
I have do to some magic around the headers to be able to intercept, mount the request with the headers and then start streaming the data. Why do you need to call Also, if you have time, try to create a test like this one https://github.com/H4ad/serverless-adapter/blob/main/test/handlers/aws-stream.handler.spec.ts#L47-L84 to be able to reproduce this issue. What http framework are you using? |
Adds logic to ensure that the actual chunk is properly identified and passed into the streaming response.
Well well, my push history is visible here, yeah I failed to read that the conventional commits are required here. 😆
My service provides some sort of "download xyz" route which a browser can call.
I added a test in my PR which just adds a
Express. Maybe this is not relevant, Let's continue in the PR. I add some other comments there later. Need to watch some infamous event now. |
This doesn't work because AWS has some issues with buffering, so only after sending 16kb of data it will actually send the data to the client (ref) |
Improve the identification of chunks in streaming responses (Fixes #260)
Hi! First: Thank you for your work on this library. It is a blessing that I can use it as a drop-in replacement for the vendia / codegenie serverless express for leveraging streaming responses in aws.
Current Behavior
I encountered a bug where only some new lines (
\r\n
) were send to the client with the AwsStreamHandler and the express framework.It turned out that something with the
writesToIgnore
counting inresponse-stream.ts
is off.Patching the library with this workaround prevents the issue:
In my case I saw using the AWS Console that my desired write had the encoding set to
undefined
.The other writes had the encoding set to
null
orlatin1
. Therefore this workaround worked for me.Expected Behavior
The correct data is send to the client.
Steps to Reproduce the Problem
Sorry, I'm currently short on time in my project, so I can't provide a proper reproduction.
I have a Screenshot of my AWS console though (pre-workaround) and I have a possible suspect.
The only thing that I use in my code which is not that common is probably the
response.flushHeaders();
call before sending any data.Else I only call
.write()
and.end()
on the express response.Other routes which do not use
response.flushHeaders();
work as expected.Screenshot:
Environment
The text was updated successfully, but these errors were encountered: