MCPcopy Create free account
hub / github.com/EvoMap/evolver / parseRetryAfterMs

Function parseRetryAfterMs

src/proxy/index.js:162–171  ·  view source on GitHub ↗
(res, bodyText)

Source from the content-addressed store, hash-verified

160// ms-precision retry_after_ms (buildRateLimitBody), fall back to the RFC
161// Retry-After header (seconds). Returns 0 when neither is present.
162function parseRetryAfterMs(res, bodyText) {
163 try {
164 const body = bodyText ? JSON.parse(bodyText) : null;
165 const ms = Number(body && body.retry_after_ms);
166 if (Number.isFinite(ms) && ms > 0) return Math.ceil(ms);
167 } catch { /* body is not JSON; fall through to the header */ }
168 const secs = Number(res && res.headers && res.headers.get && res.headers.get('retry-after'));
169 if (Number.isFinite(secs) && secs > 0) return secs * 1000;
170 return 0;
171}
172
173class EvoMapProxy {
174 constructor(opts = {}) {

Callers 2

_proxyHttpMethod · 0.85

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected