diff --git a/pkg/server/server.go b/pkg/server/server.go
index 8b822c7c6f430f8643a868be73a7712192ab2ada..8223cd848024066a8e95a63f3c87e49c5249ef28 100644
--- a/pkg/server/server.go
+++ b/pkg/server/server.go
@@ -70,7 +70,10 @@ func ServeCodec(ctx context.Context, remote jsonrpc.ReaderWriter, handler jsonrp
 			return serve(ctx, incoming, responder, handler)
 		})
 	}
-	egg.Wait()
+	err := egg.Wait()
+	if err != nil {
+		return err
+	}
 	select {
 	case <-ctx.Done():
 		return nil