@zapier/kitcore 0.17.1 → 0.17.2

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @zapier/kitcore
2
2
 
3
+ ## 0.17.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 173df80: `retryHttpRequestPlugin` now reads `X-RateLimit-Reset` values under 1e9 as seconds until the window resets (the IETF draft convention, sent by rate limiters like `@fastify/rate-limit` and Envoy) instead of always as an epoch timestamp. Previously a delta value was read as a date in 1970, the computed wait clamped to zero, and every remaining attempt resent immediately. Now the retry waits as directed, and a delta beyond `maxDelayMilliseconds` gives up and returns the 429 instead of hammering. Epoch-style values (1e9 and above, e.g. GitHub's) behave as before.
8
+
9
+ `X-RateLimit-Reset` now directs the delay only on a 429. Rate limiters attach `x-ratelimit-*` headers to every response passing through them, so on a 5xx the value describes the quota window rather than the outage; those retries now use `Retry-After` when present or exponential backoff.
10
+
3
11
  ## 0.17.1
4
12
 
5
13
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -5058,6 +5058,7 @@ var DEFAULT_IDEMPOTENT_METHODS = [
5058
5058
  ];
5059
5059
  var BASE_BACKOFF_MILLISECONDS = 1e3;
5060
5060
  var JITTER_FACTOR = 0.5;
5061
+ var EPOCH_THRESHOLD_SECONDS = 1e9;
5061
5062
  function directedDelayMilliseconds(response) {
5062
5063
  const retryAfter = response.headers.get("retry-after");
5063
5064
  if (retryAfter) {
@@ -5066,11 +5067,12 @@ function directedDelayMilliseconds(response) {
5066
5067
  const date = Date.parse(retryAfter);
5067
5068
  if (!Number.isNaN(date)) return Math.max(0, date - Date.now());
5068
5069
  }
5070
+ if (response.status !== 429) return void 0;
5069
5071
  const reset = response.headers.get("x-ratelimit-reset");
5070
5072
  if (reset) {
5071
- const resetSeconds = Number.parseInt(reset, 10);
5072
- if (!Number.isNaN(resetSeconds)) {
5073
- return Math.max(0, resetSeconds * 1e3 - Date.now());
5073
+ const resetValue = Number.parseInt(reset, 10);
5074
+ if (!Number.isNaN(resetValue)) {
5075
+ return resetValue >= EPOCH_THRESHOLD_SECONDS ? Math.max(0, resetValue * 1e3 - Date.now()) : Math.max(0, resetValue * 1e3);
5074
5076
  }
5075
5077
  }
5076
5078
  return void 0;