From 14dab311e9870ed18267bbfbba801ce54f0d8d8f Mon Sep 17 00:00:00 2001 From: "Evgeny @ SimpleX Chat" <259188159+evgeny-simplex@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:36:49 +0000 Subject: [PATCH] fix, debug --- src/Simplex/FileTransfer/Agent.hs | 3 ++- src/Simplex/Messaging/Client.hs | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Simplex/FileTransfer/Agent.hs b/src/Simplex/FileTransfer/Agent.hs index f31922117..d83983363 100644 --- a/src/Simplex/FileTransfer/Agent.hs +++ b/src/Simplex/FileTransfer/Agent.hs @@ -314,7 +314,8 @@ runXFTPRcvLocalWorker c Worker {doWork} = do case redirect of Nothing -> do notify c rcvFileEntityId $ RFDONE fsSavePath - lift $ forM_ tmpPath (removePath <=< toFSFilePath) + flip catchAllErrors (\e -> logError $ "XFTP rcv worker error: " <> tshow e) $ + lift $ forM_ tmpPath (removePath <=< toFSFilePath) liftIO $ waitUntilForeground c withStore' c (`updateRcvFileComplete` rcvFileId) Just RcvFileRedirect {redirectFileInfo, redirectDbId} -> do diff --git a/src/Simplex/Messaging/Client.hs b/src/Simplex/Messaging/Client.hs index 9989a96eb..cc3724206 100644 --- a/src/Simplex/Messaging/Client.hs +++ b/src/Simplex/Messaging/Client.hs @@ -652,7 +652,13 @@ getProtocolClient g nm transportSession@(_, srv, _) cfg@ProtocolClientConfig {qS writeTVar (connected c) True putTMVar cVar $ Right c' raceAny_ ([send c' th, process c', receive c' th] <> [monitor c' | smpPingInterval > 0]) - `E.finally` disconnected c' + `E.finally` (failPendingRequests c >> disconnected c') + + failPendingRequests :: PClient v err msg -> IO () + failPendingRequests PClient {sentCommands} = atomically $ do + rs <- swapTVar sentCommands mempty + forM_ rs $ \Request {pending, responseVar} -> + whenM (swapTVar pending False) $ void $ tryPutTMVar responseVar $ Left $ PCENetworkError NEFailedError send :: Transport c => ProtocolClient v err msg -> THandle v c 'TClient -> IO () send ProtocolClient {client_ = PClient {sndQ}} h = forever $ atomically (readTBQueue sndQ) >>= sendPending