From 4a64061aab3ad0aefb342f0806c71b3fd08c23b2 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Mon, 24 Apr 2023 18:42:30 +0400 Subject: [PATCH] wip - logs --- src/Simplex/FileTransfer/Agent.hs | 8 ++++++-- src/Simplex/FileTransfer/Client.hs | 4 +++- src/Simplex/Messaging/Transport/HTTP2/Client.hs | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Simplex/FileTransfer/Agent.hs b/src/Simplex/FileTransfer/Agent.hs index d78511d78..b2417aa8c 100644 --- a/src/Simplex/FileTransfer/Agent.hs +++ b/src/Simplex/FileTransfer/Agent.hs @@ -390,6 +390,8 @@ runXFTPSndPrepareWorker c doWork = do else pure sndFile maxRecipients <- asks (xftpMaxRecipientsPerRequest . config) let numRecipients' = min numRecipients maxRecipients + liftIO $ print "finished encrypting" + threadDelay 10000000 -- concurrently? forM_ (filter (not . chunkCreated) chunks) $ createChunk numRecipients' withStore' c $ \db -> updateSndFileStatus db sndFileId SFSUploading @@ -463,7 +465,7 @@ runXFTPSndWorker c srv doWork = do `catchError` \e -> retryOnError "XFTP snd worker" (retryLoop loop e delay') (retryDone e) e where retryLoop loop e replicaDelay = do - liftIO $ print $ "replica " <> show sndChunkReplicaId <> " temporary error" + liftIO $ print $ "replica " <> show sndChunkReplicaId <> " temporary error" <> show e flip catchError (\_ -> pure ()) $ do notifyOnRetry <- asks (xftpNotifyErrsOnRetry . config) when notifyOnRetry $ notify c sndFileEntityId $ SFERR e @@ -471,7 +473,9 @@ runXFTPSndWorker c srv doWork = do withStore' c $ \db -> updateSndChunkReplicaDelay db sndChunkReplicaId replicaDelay atomically $ assertAgentForeground c loop - retryDone e = sndWorkerInternalError c sndFileId sndFileEntityId (Just filePrefixPath) (show e) + retryDone e = do + liftIO $ print $ "replica " <> show sndChunkReplicaId <> " permanent error" <> show e + sndWorkerInternalError c sndFileId sndFileEntityId (Just filePrefixPath) (show e) uploadFileChunk :: SndFileChunk -> SndFileChunkReplica -> m () uploadFileChunk sndFileChunk@SndFileChunk {sndFileId, userId, chunkSpec = chunkSpec@XFTPChunkSpec {filePath}, digest = chunkDigest} replica = do replica'@SndFileChunkReplica {sndChunkReplicaId} <- addRecipients sndFileChunk replica diff --git a/src/Simplex/FileTransfer/Client.hs b/src/Simplex/FileTransfer/Client.hs index e54c6e2f0..8d244e9a7 100644 --- a/src/Simplex/FileTransfer/Client.hs +++ b/src/Simplex/FileTransfer/Client.hs @@ -146,7 +146,9 @@ sendXFTPCommand XFTPClient {config, http2Client = http2@HTTP2Client {sessionId}} Just e -> throwError $ PCEProtocolError e _ -> pure (r, body) Left e -> throwError $ PCEResponseError e - HTTP2RequestError e -> throwError $ PCEInternalError $ show e + HTTP2RequestError e -> do + liftIO $ print $ "in sendXFTPCommand HTTP2RequestError" <> show e + throwError $ PCEInternalError $ show e where streamBody :: ByteString -> (Builder -> IO ()) -> IO () -> IO () streamBody t send done = do diff --git a/src/Simplex/Messaging/Transport/HTTP2/Client.hs b/src/Simplex/Messaging/Transport/HTTP2/Client.hs index c7245d534..e572f6d10 100644 --- a/src/Simplex/Messaging/Transport/HTTP2/Client.hs +++ b/src/Simplex/Messaging/Transport/HTTP2/Client.hs @@ -118,6 +118,7 @@ getVerifiedHTTP2Client proxyUsername host port keyHash caStore config@HTTP2Clien process HTTP2Client {client_ = HClient {reqQ}} sendReq = forever $ do (req, resVar) <- atomically $ readTBQueue reqQ sendReq req (processResp resVar) `E.catch` \e -> do + liftIO $ print $ "in process catch e: " <> show e let res = HTTP2RequestError e atomically $ putTMVar resVar res pure res