@teincfood/core 0.10.11 → 0.10.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,13 +18,21 @@ let rateLimitHitsInWindow = 0;
18
18
  /** Record a 429: pause all sync until retryAfterMs (default 60s). */
19
19
  export function noteRateLimited(retryAfterMs) {
20
20
  const delay = retryAfterMs && retryAfterMs > 0 ? retryAfterMs : DEFAULT_RETRY_AFTER_MS;
21
- const until = Date.now() + delay;
21
+ const now = Date.now();
22
+ const until = now + delay;
22
23
  if (until > rateLimitedUntil)
23
24
  rateLimitedUntil = until;
24
- if (until > reportedWindowUntil) {
25
+ // A new reporting window starts only after the previous one has expired.
26
+ // Extending an active window (another 429, a longer Retry-After, or a
27
+ // synthesized gate rejection) must not reset the counter, otherwise every
28
+ // request reports another toast.
29
+ if (now >= reportedWindowUntil) {
25
30
  reportedWindowUntil = until;
26
31
  rateLimitHitsInWindow = 0;
27
32
  }
33
+ else if (until > reportedWindowUntil) {
34
+ reportedWindowUntil = until;
35
+ }
28
36
  rateLimitHitsInWindow += 1;
29
37
  }
30
38
  /** Milliseconds remaining in the current cooldown (0 when not throttled). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teincfood/core",
3
- "version": "0.10.11",
3
+ "version": "0.10.12",
4
4
  "description": "TeincFood shared offline-first core — types, sync engine, local DB, reference data, and repositories for mobile + desktop",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",