File tree Expand file tree Collapse file tree
src/Packages/Audience/Runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -555,10 +555,10 @@ public static async Task FlushAsync(CancellationToken cancellationToken = defaul
555555
556556 queue . FlushSync ( ) ;
557557
558- // Serialise SendBatchAsync via _sendInFlight . Without the gate,
559- // two concurrent FlushAsync callers both call ReadBatch with the
560- // same paths and double-POST. Poll cheaply while another caller
561- // (timer SendBatch or a racing FlushAsync) holds the gate .
558+ // Only one send runs at a time . Without this, two FlushAsync
559+ // callers would both read the same batch from disk and send it
560+ // twice. Yield while another caller (the timer or another
561+ // FlushAsync) holds the in-flight slot .
562562 while ( Interlocked . CompareExchange ( ref _sendInFlight , 1 , 0 ) != 0 )
563563 {
564564 cancellationToken . ThrowIfCancellationRequested ( ) ;
Original file line number Diff line number Diff line change @@ -99,9 +99,10 @@ internal async Task<bool> SendBatchAsync(CancellationToken ct = default)
9999
100100 if ( statusCode >= 200 && statusCode < 300 )
101101 {
102- // 2xx: server acked. Parse {accepted, rejected} and surface
103- // any partial rejections via onError — rejected events are
104- // validation errors, won't succeed on retry.
102+ // Server accepted the batch. Count how many messages it
103+ // rejected; if any, tell the studio via onError. Rejected
104+ // messages are validation failures — retrying won't help,
105+ // so the batch is deleted either way.
105106 var rejected = await ParseRejectedCount ( response ) . ConfigureAwait ( false ) ;
106107 _store . Delete ( batch ) ;
107108 ResetBackoff ( ) ;
@@ -233,9 +234,9 @@ private void ResetBackoff()
233234 return sb . ToString ( ) ;
234235 }
235236
236- // Reads the body and extracts "rejected". Returns 0 on any parse or
237- // read failure — the body is diagnostic, so a malformed one must not
238- // block the success path.
237+ // Reads the response body and pulls out the "rejected" count . Returns
238+ // 0 if the body is missing or unreadable — the body is only for
239+ // reporting, so failing to read it must not break the success path.
239240 private static async Task < int > ParseRejectedCount ( HttpResponseMessage response )
240241 {
241242 string body ;
You can’t perform that action at this time.
0 commit comments