File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -919,9 +919,8 @@ func (a *agent) trackScriptLogs(ctx context.Context, reader io.ReadCloser) (chan
919
919
sendDone := make (chan struct {})
920
920
send := make (chan []agentsdk.StartupLog , 1 )
921
921
go func () {
922
- flushTimeout := 100 * time .Millisecond
922
+ flushTimeout := 250 * time .Millisecond
923
923
flush := time .NewTimer (flushTimeout )
924
- flush .Stop ()
925
924
926
925
var backlog []agentsdk.StartupLog
927
926
defer func () {
@@ -957,6 +956,8 @@ func (a *agent) trackScriptLogs(ctx context.Context, reader io.ReadCloser) (chan
957
956
}
958
957
959
958
if (done || flushed ) && len (backlog ) > 0 {
959
+ flush .Stop () // Decrease the chance of a double flush.
960
+
960
961
// Retry uploading logs until successful or a specific
961
962
// error occurs.
962
963
for r := retry .New (time .Second , 5 * time .Second ); r .Wait (ctx ); {
@@ -983,12 +984,14 @@ func (a *agent) trackScriptLogs(ctx context.Context, reader io.ReadCloser) (chan
983
984
return
984
985
}
985
986
backlog = nil
987
+
988
+ // Only reset after send to ensure we send logs approximately
989
+ // every flushTimeout (or every 100 rows).
990
+ flush .Reset (flushTimeout )
986
991
}
987
992
if done {
988
993
return
989
994
}
990
-
991
- flush .Reset (flushTimeout )
992
995
}
993
996
}()
994
997
You can’t perform that action at this time.
0 commit comments