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

warp terminates silently #603

Open
agrafix opened this issue Jan 3, 2017 · 3 comments
Open

warp terminates silently #603

agrafix opened this issue Jan 3, 2017 · 3 comments

Comments

@agrafix
Copy link

agrafix commented Jan 3, 2017

On a system I've observed that a web server application written using warp sometimes terminates with exit code 0 for 'no reason'. After some debugging, I noticed that it ran out of file descriptors. The problem lies here:

acceptLoop = do
-- Allow async exceptions before receiving the next connection maker.
allowInterrupt
-- acceptNewConnection will try to receive the next incoming
-- request. It returns a /connection maker/, not a connection,
-- since in some circumstances creating a working connection
-- from a raw socket may be an expensive operation, and this
-- expensive work should not be performed in the main event
-- loop. An example of something expensive would be TLS
-- negotiation.
mx <- acceptNewConnection
case mx of
Nothing -> return ()
Just (mkConn, addr) -> do
fork set mkConn addr app counter ii0
acceptLoop
acceptNewConnection = do
ex <- try getConnMaker
case ex of
Right x -> return $ Just x
Left e -> do
let eConnAborted = getErrno eCONNABORTED
getErrno (Errno cInt) = cInt
if ioe_errno e == Just eConnAborted
then acceptNewConnection
else do
settingsOnException set Nothing $ toException e
return Nothing
. With the default configuration, the exception is NOT logged and the runLoop simply terminates. I think it should always log the expection in default configuration if the server terminates. (Maybe even rethrow?)

@snoyberg
Copy link
Member

snoyberg commented Jan 3, 2017

Reading through that code, shouldn't settingsOnException be able to print the exception?

@agrafix
Copy link
Author

agrafix commented Jan 3, 2017

Yes, but I think the default defaultOnException with defaultShouldDisplayException misses the out of file descriptors exceptions and thus does not print it

@snoyberg
Copy link
Member

snoyberg commented Jan 3, 2017

Here's the relevant code:

https://www.stackage.org/haddock/lts-7.14/warp-3.2.9/src/Network.Wai.Handler.Warp.Settings.html#defaultShouldDisplayException

Which of those clauses is catching the out of file descriptors exception?

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

No branches or pull requests

2 participants