-
Notifications
You must be signed in to change notification settings - Fork 128
replace preconditions with errors #64
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. It would be nice to have some tests which would have hit the preconditions and now catch a graceful failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks great, thanks!
I'm trying to add a test, but it's not that straitforward :) NIO is pretty good at detecting when you do stupid things in your |
Test added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I agree with this patch. SwiftNIO will never (and if it did that'd be a serious bug) send you anything but exactly 1 .head
, 0...
.body
, 1 .end
. This is hiding bugs and isn't actionable to the user.
What was the motivation for this?
@weissi I think |
@artemredkin cool, but that should be fixed then, no? |
Question is, why task futureResult callback is called so late? It seems we need to call context.close right away in all cases |
@artemredkin mind fixing the PR description and adding a good explanation of when exactly this will help? Also we definitely need a test case that proves this is effective. |
@weissi done |
This is not needed at all, underlying problem is solved by NIO: |
@artemredkin released as swift-nio 2.6.1 |
Will address #49 as well
Before this PR,
channel.close
was called afterTask
promise was fulfilled. This introduced a slight delay before receiving.end
and closing the channel. This in turn could lead to a situation where we could receive.head
right after.end
, which is allowed by HTTP protocol (keep-alive) but is not currently supported (pending connection pool work) byResponseAccumulator
. In order to address this, we need to close channel immediately after receiving.end
.