Skip to content

Open connections are leaking #490

Closed
@neongreen

Description

@neongreen

I do a bunch of SQS.deleteMessages in a loop, and experience long waits (5-10 seconds) after getting 99 open connections. This happens with https://github.com/iain/fake_sqs (I haven't tested with real SQS).

This behavior is introduced by a recent commit (made after 1.6.0 was released): 2688190.

My guess is that in the absence of finalizers in conduit-1.3, nothing is closing connections open by Responses. The following diff fixes the behavior of deleteMessage for me:

diff --git a/core/src/Network/AWS/Response.hs b/core/src/Network/AWS/Response.hs
index 4791de6a3c..907b0faa05 100644
--- a/core/src/Network/AWS/Response.hs
+++ b/core/src/Network/AWS/Response.hs
@@ -45,8 +45,9 @@ receiveNull :: (MonadResource m, MonadThrow m)
             -> Proxy a
             -> ClientResponse
             -> m (Response a)
-receiveNull rs _ = stream $ \_ _ x ->
-    liftResourceT (x `connect` pure (Right rs))
+receiveNull rs _ = stream $ \_ _ x -> do
+    sinkLBS x
+    pure (Right rs)

 receiveEmpty :: (MonadResource m, MonadThrow m)
              => (Int -> ResponseHeaders -> () -> Either String (Rs a))

It's still slower than it used to be (I've no idea why), but at least it doesn't leak connections anymore and I get no stuck requests.

Other receiveBlah functions might also be affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions