Switched to time-based domain warmup#22
Conversation
| return Math.min(scaledIncrease, absoluteIncrease); | ||
| async getWarmupLimit(emailCount: number): Promise<number> { | ||
| const day = await this.#getDaysSinceFirstEmail() | ||
| if (day > this.#warmupConfig.totalDays) { |
There was a problem hiding this comment.
🔴 Off-by-one error in warmup completion check causes day 42 to not return Infinity
The warmup completion check uses day > this.#warmupConfig.totalDays but should use >= to correctly mark warmup as complete.
Click to expand
Problem
With totalDays = 42, the formula day / (totalDays - 1) is designed so that:
- Day 0 →
0/41 = 0→ returns start value (200) - Day 41 →
41/41 = 1→ returns end value (200000) - Day 42+ → should return
Infinity(warmup complete)
However, the condition at line 85 is day > this.#warmupConfig.totalDays, which means:
42 > 42evaluates tofalse- Day 42 calculates:
200 * (1000)^(42/41) ≈ 236701instead of returningInfinity
Actual vs Expected
// Day 42 with current code:
day > 42 // 42 > 42 = false, so continues to calculate
limit = 236701
// Day 42 with fix:
day >= 42 // 42 >= 42 = true, returns InfinityImpact
After 42 days of warmup, the service should allow unlimited emails from the custom domain. Instead, it continues calculating limits, which could restrict email sending unnecessarily. The unit test at domain-warming-service.test.ts:284-301 expects Infinity for day 42 and would fail with the current implementation.
Recommendation: Change if (day > this.#warmupConfig.totalDays) to if (day >= this.#warmupConfig.totalDays) to correctly return Infinity when the warmup period is complete.
Was this helpful? React with 👍 or 👎 to provide feedback.
Benchmark PR from qodo-benchmark#236