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

HTTP::Client spec: don't write server response if expecting read timeout #7402

Merged

Conversation

asterite
Copy link
Member

@asterite asterite commented Feb 9, 2019

Fixes #7401

I found out that the problem was in the "tests read_timeout" spec. This fixes it but I'm not entirely sure why the exception happens.

What I think happens is:

  • the client is set a read timeout, and it will timeout
  • the server is said to wait for more time than that of the read timeout and then write a response
  • by the time the server gets to write the response, the client's socket might be already closed because the GC already finalized it

At least I couldn't reproduce it with GC_DONT_GC=1 (but then it failed because of too many open file requests), so I'm not sure. But I think my logic above is correct.

In this PR, when we expect a read timeout to happen we don't even bother instructing the server to write a response because that doesn't matter anymore.

However, this leads me to think... if I write an HTTP server and I accept a request and the client closes the socket before I get to write the response... an exception will be raised and it will be printed in the server's spawn handling that request. Is that OK? How do other languages handle this?

@bew
Copy link
Contributor

bew commented Feb 9, 2019

if I write an HTTP server and I accept a request and the client closes the socket before I get to write the response... an exception will be raised and it will be printed in the server's spawn handling that request. Is that OK?

That's what I would expect at least..

@asterite
Copy link
Member Author

asterite commented Feb 9, 2019

Ugh, that failure in darwin... come on, CI, I'm trying my best here, don't give me new errors...

@asterite
Copy link
Member Author

For history purposes, this is the darwin build that failed: https://circleci.com/gh/crystal-lang/crystal/18231?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

I'll re-run it now.

@asterite asterite force-pushed the bug/http-client-spec-read-timeout branch from 054a455 to 7725449 Compare February 10, 2019 14:36
@straight-shoota
Copy link
Member

I'm pretty sure the immediate issue should be fixed by #7197.

@asterite
Copy link
Member Author

@straight-shoota
Copy link
Member

That's already tracked in #7243

@asterite
Copy link
Member Author

We can probably merge this PR first, which is really small, and then focus on reviewing #7197, which is much larger and also is currently failing on my machine.

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

I'm not sure if this would really be required to keep in the long run, but it's fine by me.

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:specs labels Feb 11, 2019
@asterite asterite added this to the 0.28.0 milestone Feb 11, 2019
@asterite asterite merged commit a0168cb into crystal-lang:master Feb 11, 2019
@asterite asterite deleted the bug/http-client-spec-read-timeout branch March 30, 2019 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:specs topic:stdlib:networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Unhandled exception in spawn: Error writing to socket: Broken pipe (Errno)" in socket client specs
5 participants