@drawcall/market 0.8.3 → 0.8.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAEzD,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAA;AAW7D,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AA2BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,qBAA0B,GAAG,cAAc,CAO7E"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,eAAe,CAAA;AAEzD,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAA;AAa7D,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AA4BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,qBAA0B,GAAG,cAAc,CAO7E"}
package/dist/v1/client.js CHANGED
@@ -2,12 +2,14 @@ import { createORPCClient } from '@orpc/client';
2
2
  import { OpenAPILink } from '@orpc/openapi-client/fetch';
3
3
  import { contract } from './contract.js';
4
4
  const DEFAULT_BASE_URL = 'https://market.drawcall.ai';
5
- /** Reads answer in well under a second; silence this long is a stalled
6
- * connection (observed in bursts between Fly and Cloudflare), not a slow
7
- * answer. Three attempts bound the worst case at ~9s while keeping one
8
- * stall to a ~3s detour. */
9
- const READ_TIMEOUT_MS = 3_000;
10
- const READ_ATTEMPTS = 3;
5
+ /**
6
+ * Escalating read deadlines: the first bounds a stalled connection (observed
7
+ * in bursts between Fly and Cloudflare) to a short detour, the later ones
8
+ * leave room for an endpoint that is legitimately slow under load — a fixed
9
+ * short timeout there turns load into a cancel-and-retry storm. Jittered
10
+ * pauses between attempts keep concurrent clients from retrying in lockstep.
11
+ */
12
+ const READ_TIMEOUT_STEPS_MS = [5_000, 10_000, 20_000];
11
13
  /**
12
14
  * GETs are idempotent, so a stalled connection is retried on a fresh one with a
13
15
  * bounded timeout — an unbounded hang in one read would otherwise hang whole
@@ -19,16 +21,17 @@ function resilientReads(baseFetch) {
19
21
  if (method !== 'GET' && method !== 'HEAD')
20
22
  return baseFetch(input, init);
21
23
  let lastError;
22
- for (let attempt = 1; attempt <= READ_ATTEMPTS; attempt++) {
23
- const timeout = AbortSignal.timeout(READ_TIMEOUT_MS);
24
+ for (const [attempt, timeoutMs] of READ_TIMEOUT_STEPS_MS.entries()) {
25
+ const timeout = AbortSignal.timeout(timeoutMs);
24
26
  const signal = init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
25
27
  try {
26
28
  return await baseFetch(input, { ...init, signal });
27
29
  }
28
30
  catch (error) {
29
31
  lastError = error;
30
- if (init?.signal?.aborted || attempt === READ_ATTEMPTS)
32
+ if (init?.signal?.aborted || attempt === READ_TIMEOUT_STEPS_MS.length - 1)
31
33
  throw error;
34
+ await new Promise((resolve) => setTimeout(resolve, 200 + Math.random() * 400));
32
35
  }
33
36
  }
34
37
  throw lastError;
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/v1/client.ts"],"names":[],"mappings":"AAAA,O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AG,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,IAAI;QAC9D,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACrF,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS;KACpF,CAAC,CAAA;IACF,OAAO,gBAAgB,CAAiB,IAAI,CAAC,CAAA;AAC/C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawcall/market",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/drawcall-ai/market",
package/src/v1/client.ts CHANGED
@@ -7,12 +7,14 @@ export type MarketV1Client = ContractRouterClient<V1Contract>
7
7
 
8
8
  const DEFAULT_BASE_URL = 'https://market.drawcall.ai'
9
9
 
10
- /** Reads answer in well under a second; silence this long is a stalled
11
- * connection (observed in bursts between Fly and Cloudflare), not a slow
12
- * answer. Three attempts bound the worst case at ~9s while keeping one
13
- * stall to a ~3s detour. */
14
- const READ_TIMEOUT_MS = 3_000
15
- const READ_ATTEMPTS = 3
10
+ /**
11
+ * Escalating read deadlines: the first bounds a stalled connection (observed
12
+ * in bursts between Fly and Cloudflare) to a short detour, the later ones
13
+ * leave room for an endpoint that is legitimately slow under load — a fixed
14
+ * short timeout there turns load into a cancel-and-retry storm. Jittered
15
+ * pauses between attempts keep concurrent clients from retrying in lockstep.
16
+ */
17
+ const READ_TIMEOUT_STEPS_MS = [5_000, 10_000, 20_000]
16
18
 
17
19
  export interface MarketV1ClientOptions {
18
20
  baseUrl?: string
@@ -31,14 +33,15 @@ function resilientReads(baseFetch: typeof globalThis.fetch): typeof globalThis.f
31
33
  if (method !== 'GET' && method !== 'HEAD') return baseFetch(input, init)
32
34
 
33
35
  let lastError: unknown
34
- for (let attempt = 1; attempt <= READ_ATTEMPTS; attempt++) {
35
- const timeout = AbortSignal.timeout(READ_TIMEOUT_MS)
36
+ for (const [attempt, timeoutMs] of READ_TIMEOUT_STEPS_MS.entries()) {
37
+ const timeout = AbortSignal.timeout(timeoutMs)
36
38
  const signal = init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout
37
39
  try {
38
40
  return await baseFetch(input, { ...init, signal })
39
41
  } catch (error) {
40
42
  lastError = error
41
- if (init?.signal?.aborted || attempt === READ_ATTEMPTS) throw error
43
+ if (init?.signal?.aborted || attempt === READ_TIMEOUT_STEPS_MS.length - 1) throw error
44
+ await new Promise((resolve) => setTimeout(resolve, 200 + Math.random() * 400))
42
45
  }
43
46
  }
44
47
  throw lastError