From 938e0d77dd28768f25430d5cdf71f7648a5223c4 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Tue, 24 Nov 2020 13:49:31 +0100 Subject: [PATCH] Don't return an error on datasync Send if an error is returned on the Send function, datasync will keep retrying a message at each epoch. If the message cannot be sent (for example is too large), then no messages will be sent until logout. --- protocol/datasync/transport.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/protocol/datasync/transport.go b/protocol/datasync/transport.go index 9d49e40e1..14278706a 100644 --- a/protocol/datasync/transport.go +++ b/protocol/datasync/transport.go @@ -59,7 +59,6 @@ func (t *NodeTransport) Watch() transport.Packet { } func (t *NodeTransport) Send(_ state.PeerID, peer state.PeerID, payload protobuf.Payload) error { - var lastError error if t.dispatch == nil { return errNotInitialized } @@ -74,21 +73,25 @@ func (t *NodeTransport) Send(_ state.PeerID, peer state.PeerID, payload protobuf data, err := proto.Marshal(payload) if err != nil { - return err + t.logger.Error("failed to marshal payload") + continue } publicKey, err := datasyncpeer.IDToPublicKey(peer) if err != nil { - return err + t.logger.Error("failed to conver id to public key", zap.Error(err)) + continue } + // We don't return an error otherwise datasync will keep + // re-trying sending at each epoch err = t.dispatch(context.Background(), publicKey, data, payload) if err != nil { - lastError = err t.logger.Error("failed to send message", zap.Error(err)) continue } } - return lastError + + return nil } func splitPayloadInBatches(payload *protobuf.Payload, maxSizeBytes int) []*protobuf.Payload {