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
Prevent vapor streaming requests from randomly losing a first chunk, stalling the request #2917
Conversation
…stalling the request
@Joannis still got test failures |
Deadlocks are a b— |
Haven't had the time to find a better solution yet due to time constraints |
…s called from the eventloop, our test works
if self.eventLoop.inEventLoop { | ||
write0(chunk, promise: promise) | ||
} else { | ||
self.eventLoop.execute { |
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.
It is my understanding that EventLoop.execute(_:)
already does the "is in event loop" check internally, which in addition, can return false negatives in the normal course of execution - If the problem is that you were executing on the event loop unconditionally before and are skipping the extra "hop", this isn't a guaranteed solution.
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.
It's not supposed to be a guaranteed solution either. The main reason is that I think it's a waste of a hop. And it does always queue it for the next tick. Not only does it fix the test, it also is a good optimisation to have.
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.
Ideally, the test's assumption is to be fixed as well of course.
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.
Thanks!
These changes are now available in 4.67.5 |
Fixes a bug where a streaming body from a request was not processing a chunk, causing the request to stall. This happened when a handler was being set at the exact moment a chunk was being processed, causing the chunk to be added to a now irrelevant array that was just processed while switching to a streaming callback.
See #2906