Skip to content
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

Abort response on stream error mid-response #2121

Closed
hueniverse opened this issue Nov 10, 2014 · 5 comments
Closed

Abort response on stream error mid-response #2121

hueniverse opened this issue Nov 10, 2014 · 5 comments
Assignees
Labels
bug Bug or defect feature New functionality or improvement

Comments

@hueniverse
Copy link
Contributor

If a 200 response using a stream fails, the client will get an incomplete 200 response instead of a complete 500.

@hueniverse hueniverse added feature New functionality or improvement bug Bug or defect labels Nov 10, 2014
@hueniverse
Copy link
Contributor Author

Not worth the complexity.

@feugy
Copy link

feugy commented Dec 20, 2016

Hi !

Just in case, is this behaviour still complex to fix ?
I'm proxying data from S3 using streams, and would like to return a 404 when downloaded file doesn't exists, or a 500 when download failed for any other reason.

It's easy to mitigate the first, by testing the file existence, but I don't see any possibility to do the second.

Thanks in advance for your time !

@hueniverse
Copy link
Contributor Author

No easy solution. Once you start piping the stream, you already set the status code.

@Marsup
Copy link
Contributor

Marsup commented Mar 6, 2017

Facing the same issue, it seems adding request.raw.res.destroy() after

request.emit('disconnect');
is sufficient to at least let the browser know something went wrong (aka forcefully interrupting the connection). See any downside to this ?

@kanongil
Copy link
Contributor

kanongil commented Mar 6, 2017

Forcefully closing the socket is the only, and best, option there is. This is probably something that hapi should do already. Otherwise, the client will just wait for data that is never coming. Worse, if it is a http keep-alive request, it can have pending pipelined requests that will never be fulfilled.

The client should be able to deduce that it received a partial response, and handle it however it sees fit.

@hueniverse hueniverse reopened this Mar 20, 2017
@hueniverse hueniverse changed the title Try change the response status to 500 on stream error mid-response Abort response on stream error mid-response Jun 22, 2017
@hueniverse hueniverse self-assigned this Jun 22, 2017
hueniverse added a commit that referenced this issue Jul 17, 2017
hueniverse added a commit that referenced this issue Jul 17, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

4 participants