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

Convert ResourceVanished error to ConnectionClosedByPeer exception an… #795

Merged

Conversation

marinelli
Copy link
Contributor

…d refine the catching

Hi everyone. At @typeable, we have a big web application, one of its components is a web API served by a warp+wai+servant server. Every request takes a lot of time to be resolved due to connections to multiple external interfaces. If I close the http client (for example killing curl or closing the browser), warp returns an error like Network.Socket.sendBuf: resource vanished (Broken pipe).

The reason is that the function socketConnection, in the Network.Wai.Handler.Warp.Run module, calls the sendAll function (from the Network.Socket.ByteString module) but the remote http client has already closed the connection.

I tried to create a simple example to reproduce this error, without success.
It might be related to #196 or some bad interactions between warp+wai and the servant application. I have to admit that I still don't know the reason.

Anyway, inspired by this old issue #421, I think it would be good to catch the IOException with error type ResourceVanished and throw a ConnectionClosedByPeer, like has been done in the Network.Wai.Handler.WarpTLS module.

I also refined the exception catching for both the warp and warp-tls package like was suggested here 91d0546#r12752366.

What do you think?

Copy link
Member

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me. @kazu-yamamoto can you give this a check as well?

@marinelli marinelli force-pushed the warp-catch-resource-vanished branch from 544561e to 1b3a92a Compare March 25, 2020 19:24
@marinelli
Copy link
Contributor Author

Hi @kazu-yamamoto,
If I may, what do you think about this solution?

@kazu-yamamoto kazu-yamamoto self-requested a review April 4, 2020 03:46
Copy link
Contributor

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

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

LGTM.

@kazu-yamamoto kazu-yamamoto merged commit 684e524 into yesodweb:master Apr 4, 2020
@kazu-yamamoto
Copy link
Contributor

Sorry for the delay. I didn't notice this. I have merged this PR.
If you would like to have a new release, please let me know.

@marinelli
Copy link
Contributor Author

It would be helpful to have a new release.

@kazu-yamamoto
Copy link
Contributor

@snoyberg This changed the behavior. Would you suggest a new version number?

@snoyberg
Copy link
Member

snoyberg commented Apr 8, 2020 via email

@kazu-yamamoto
Copy link
Contributor

@snoyberg Did you mean that 3.3.10 is good enough?

@snoyberg
Copy link
Member

snoyberg commented Apr 8, 2020

Yes I think it's fine

@kazu-yamamoto
Copy link
Contributor

@snoyberg Thank you!

@kazu-yamamoto
Copy link
Contributor

3.3.10 has been released.

@marinelli
Copy link
Contributor Author

Thank you everyone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants