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

Draining bug fix #4750

Merged
merged 9 commits into from Apr 18, 2021
Merged

Draining bug fix #4750

merged 9 commits into from Apr 18, 2021

Conversation

RaasAhsan
Copy link
Member

@RaasAhsan RaasAhsan commented Apr 15, 2021

Fixes #4731. The issue here was that we would drain a socket's read buffer before the response was written to the socket. This can manifest in the aforementioned bug because the input stream will only be evaluated when we try to write. But if we drain the connection before we write, we'll end up closing because we see unread bytes.

So the fix is to drain after the response is written to the socket. I've also done some QoL to make things easier to read and follow. There might be some merge conflicts with #4735 which I can deal with

TODO:

  • Tests (Daniel's reproduction is a good one)
  • Run some more tests locally for this

@RaasAhsan RaasAhsan marked this pull request as ready for review April 15, 2021 14:54
Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't die on the case class hill.


package org.http4s.ember.core

private[ember] final case class EmptyStreamError() extends Exception("Cannot Parse Empty Stream")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't love exceptions being case classes. It implies equality where there is none. I see you're using it as an extractor, but I usually catch these by type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also not a hill I'll die on, but every other exception type defined in that package is also a case class, and most of them are not used in a match clause :) . If we want to go one way or the other, I'm all for for following well-defined guidelines

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I care about consistency more than which way we go. Let's merge, and we can revisit the case class bikeshed.

@rossabaker rossabaker added the bug Determined to be a bug in http4s label Apr 15, 2021
@rossabaker rossabaker merged commit 944ad3a into http4s:series/0.21 Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Determined to be a bug in http4s module:ember-server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants