Skip to content

Commit 73c20eb

Browse files
fix(audience): restore 40s step in HttpTransport backoff schedule
Reverses the schedule narrowing from 0e6c121. The doubled progression (5s → 10s → 20s → 40s → 60s) gives one extra "soft" backoff step before hitting the cap and matches the original bitshift formula's natural shape. The 4× jump from 20s → 60s in the previous schedule was asymmetric; this restores clean doubling at every step. The plan document this conflicts with should be updated to match. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 995886d commit 73c20eb

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/Packages/Audience/Runtime/Transport/HttpTransport.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,15 @@ internal async Task<bool> SendBatchAsync(CancellationToken ct = default)
122122

123123
/// <summary>
124124
/// Backoff delay in milliseconds based on consecutive failures.
125-
/// Schedule per plan: 0 → 5s → 10s → 20s → 60s cap.
125+
/// Schedule: 0 → 5s → 10s → 20s → 40s → 60s cap.
126126
/// </summary>
127127
internal int BackoffMs => _consecutiveFailures switch
128128
{
129129
<= 0 => 0,
130130
1 => 5_000,
131131
2 => 10_000,
132132
3 => 20_000,
133+
4 => 40_000,
133134
_ => 60_000,
134135
};
135136

src/Packages/Audience/Tests/Runtime/HttpTransportTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public async Task BackoffMs_EscalatesOnlyAfterWindowElapsed()
173173
using var transport = new HttpTransport(_store, "pk_imapik-test-key1",
174174
handler: handler, getUtcNow: _getUtcNow);
175175

176-
// Schedule per plan: 5s → 10s → 20s → 60s cap (no 40s step).
176+
// Schedule: 5s → 10s → 20s → 40s → 60s cap.
177177
// Each escalation requires the previous window to have elapsed.
178178
await transport.SendBatchAsync();
179179
Assert.AreEqual(5_000, transport.BackoffMs);
@@ -188,7 +188,11 @@ public async Task BackoffMs_EscalatesOnlyAfterWindowElapsed()
188188

189189
Advance(20_001);
190190
await transport.SendBatchAsync();
191-
Assert.AreEqual(60_000, transport.BackoffMs, "jumps to 60s cap after 20s");
191+
Assert.AreEqual(40_000, transport.BackoffMs);
192+
193+
Advance(40_001);
194+
await transport.SendBatchAsync();
195+
Assert.AreEqual(60_000, transport.BackoffMs, "reaches 60s cap after 40s step");
192196

193197
Advance(60_001);
194198
await transport.SendBatchAsync();

0 commit comments

Comments
 (0)