stitchkit 0.136.3 → 0.136.4
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 +7 -0
- package/dist/browser/http-fetch.d.ts +6 -0
- package/dist/browser/http-fetch.d.ts.map +1 -1
- package/dist/browser/http-helpers.d.ts +21 -0
- package/dist/browser/http-helpers.d.ts.map +1 -1
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +3 -3
- package/dist/entrypoints/index.js +3 -3
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +2 -2
- package/dist/entrypoints/testing.js +2 -2
- package/dist/{index-nne3yxew.js → index-6f4fjygr.js} +1 -1
- package/dist/{index-rw31t8sj.js → index-9fzjgg86.js} +1 -1
- package/dist/{index-mhgkzwxz.js → index-d01akj5n.js} +134 -25
- package/llms/stitchkit.txt +10 -2
- package/llms-full.txt +10 -2
- package/llms.txt +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,13 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [0.136.4] - 2026-12-03
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `stitchkit`, `stitchkit/http` — `createHttpClient` retries with a request body (such as an `idempotent: true` `POST`, `PUT`, or `PATCH` with JSON or `FormData`) now buffer the body into concrete `ArrayBuffer` bytes with headers copied beforehand, instead of forwarding `Request.body` (`ReadableStream`) with `duplex: 'half'`. Previously Chromium rejected such retries over HTTP/1.1 with `net::ERR_ALPN_NEGOTIATION_FAILED` before sending the request, causing recoverable network failures to exhaust retries and fail with `ApiError` (`UNKNOWN_ERROR`, `status: 0`) wrapping Ky's `NetworkError`; WebKit/Safari do not support streaming request bodies either, and non-Streams Fetch polyfills (such as React Native's `whatwg-fetch`, where `Request.body` is `undefined`) now forward the `Request` without losing its body. Calls whose method is not retriable now pass `retry: { limit: 0 }` to Ky so Ky skips `Request.prototype.clone()`, keeping the body as direct bytes visible to browser DevTools Protocol and Playwright `request.postData()`, while `createHttpClient` validates `config.retry` upfront and guards `FormData` checks when `FormData` is absent from the global realm.
|
|
23
|
+
**Affects:** `stitchkit` createHttpClient, createClient, createClients, createScopedClients; `stitchkit/http` createHttpClient, createClient, createClients, createScopedClients
|
|
24
|
+
|
|
18
25
|
## [0.136.3] - 2026-12-02
|
|
19
26
|
|
|
20
27
|
### Fixed
|
|
@@ -13,6 +13,12 @@ export type ParamArrayValue = Array<string | number>;
|
|
|
13
13
|
* Its patched fetch merges `init` into Request inputs first, so retries use a
|
|
14
14
|
* URL plus a materialized init while the untouched first attempt keeps the
|
|
15
15
|
* exact Ky Request.
|
|
16
|
+
*
|
|
17
|
+
* When the Request carries a body, buffer it into concrete `ArrayBuffer` bytes
|
|
18
|
+
* instead of forwarding `input.body` (`ReadableStream`) with `duplex: 'half'`:
|
|
19
|
+
* Chromium refuses streaming request bodies over HTTP/1.1
|
|
20
|
+
* (`net::ERR_ALPN_NEGOTIATION_FAILED`), WebKit does not support them, and
|
|
21
|
+
* buffering also works in Node/Undici without `duplex`.
|
|
16
22
|
*/
|
|
17
23
|
export declare function createRetryAwareFetch(transportFetch: ClientFetch, unix?: string): NonNullable<Options['fetch']>;
|
|
18
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-fetch.d.ts","sourceRoot":"","sources":["../../src/browser/http-fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"http-fetch.d.ts","sourceRoot":"","sources":["../../src/browser/http-fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAC/D,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AAmHrD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,WAAW,EAC3B,IAAI,CAAC,EAAE,MAAM,GACZ,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CA0C/B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,eAAe,CAAC,GACnD,MAAM,GAAG,SAAS,CAgBpB;AAED,oFAAoF;AACpF,wBAAsB,YAAY,CAAC,CAAC,EAClC,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,GAC9D,OAAO,CAAC,CAAC,CAAC,CAmBZ"}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
import { type Options } from 'ky';
|
|
1
2
|
import { ApiError } from './api-error.js';
|
|
2
3
|
import type { ApiEvent, HttpClientConfig } from './http.js';
|
|
4
|
+
/** Validated, immutable retry configuration snapshot for `createHttpClient`. */
|
|
5
|
+
export interface NormalizedClientRetry {
|
|
6
|
+
readonly limit: number;
|
|
7
|
+
readonly methods: readonly string[];
|
|
8
|
+
readonly methodSet: ReadonlySet<string>;
|
|
9
|
+
readonly statusCodes: readonly number[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Validate `HttpClientConfig.retry` upfront so non-retriable calls (which pass
|
|
13
|
+
* `retry: { limit: 0 }` to skip Ky's `Request.clone()`) never mask an invalid
|
|
14
|
+
* client retry configuration, and caller array mutations never drift from Ky.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeClientRetryConfig(retry: HttpClientConfig['retry']): NormalizedClientRetry;
|
|
17
|
+
/**
|
|
18
|
+
* Per-call Ky `retry` override: non-retriable calls pass `{ limit: 0 }` so Ky
|
|
19
|
+
* skips `Request.prototype.clone()`, keeping the request body as direct bytes
|
|
20
|
+
* in browsers; `idempotent: true` adds the call's method while keeping the
|
|
21
|
+
* client's limit and status codes.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveCallRetry(retry: NormalizedClientRetry, method: string, idempotent: boolean | undefined): Options['retry'] | undefined;
|
|
3
24
|
/** `fetch` and `unix` are two transports; a unix socket needs Bun's own fetch. */
|
|
4
25
|
export declare function assertTransportChoice(config: HttpClientConfig): void;
|
|
5
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-helpers.d.ts","sourceRoot":"","sources":["../../src/browser/http-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-helpers.d.ts","sourceRoot":"","sources":["../../src/browser/http-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,IAAI,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAKzD,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAC/B,qBAAqB,CA2BvB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,qBAAqB,EAC5B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,OAAO,GAAG,SAAS,GAC9B,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,CAK9B;AAED,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAcpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,QAAQ,CAoBxF;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEvD;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAOlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/browser/http.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAaxD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,UAAU,EAGhB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/browser/http.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAaxD,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,UAAU,EAGhB,MAAM,cAAc,CAAC;AAWtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,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C,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3E,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC1E,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7D,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAS,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAAC;IAClD,gFAAgF;IAChF,MAAM,IAAI,IAAI,CAAC;IACf,oEAAoE;IACpE,gBAAgB,IAAI,IAAI,CAAC;CAC1B;AAED,gFAAgF;AAChF,MAAM,WAAW,oBAAqB,SAAQ,UAAU;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAWD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CAmM/E"}
|
package/dist/entrypoints/http.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
createBridgeClosedError,
|
|
22
22
|
createUnusableReplyError,
|
|
23
23
|
createHttpClient2
|
|
24
|
-
} from "../index-
|
|
24
|
+
} from "../index-d01akj5n.js";
|
|
25
25
|
import {
|
|
26
26
|
contractEndpointMatchers2,
|
|
27
27
|
createClient2,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
createUrlBuilder2,
|
|
31
31
|
createUrlBuilders2,
|
|
32
32
|
createScopedUrlBuilders2
|
|
33
|
-
} from "../index-
|
|
33
|
+
} from "../index-6f4fjygr.js";
|
|
34
34
|
import"../index-gvgtmt7a.js";
|
|
35
35
|
import"../index-yt1gg11x.js";
|
|
36
36
|
import"../index-werjqesf.js";
|
|
@@ -38,7 +38,7 @@ import"../index-dmrx8xma.js";
|
|
|
38
38
|
import {
|
|
39
39
|
uploadInChunks2,
|
|
40
40
|
readContractIdentity2
|
|
41
|
-
} from "../index-
|
|
41
|
+
} from "../index-9fzjgg86.js";
|
|
42
42
|
import {
|
|
43
43
|
StreamLineLimitError2,
|
|
44
44
|
StreamTruncatedLineError2
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "../index-yrhw10ef.js";
|
|
10
10
|
import {
|
|
11
11
|
createHttpClient2
|
|
12
|
-
} from "../index-
|
|
12
|
+
} from "../index-d01akj5n.js";
|
|
13
13
|
import {
|
|
14
14
|
parseNDJSON2,
|
|
15
15
|
createNDJSONDecoder2,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
createUrlBuilder2,
|
|
22
22
|
createUrlBuilders2,
|
|
23
23
|
createScopedUrlBuilders2
|
|
24
|
-
} from "../index-
|
|
24
|
+
} from "../index-6f4fjygr.js";
|
|
25
25
|
import {
|
|
26
26
|
ContractFingerprintSchema2,
|
|
27
27
|
contractFingerprint2,
|
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
import {
|
|
88
88
|
uploadInChunks2,
|
|
89
89
|
readContractIdentity2
|
|
90
|
-
} from "../index-
|
|
90
|
+
} from "../index-9fzjgg86.js";
|
|
91
91
|
import {
|
|
92
92
|
StreamLineLimitError2,
|
|
93
93
|
StreamTruncatedLineError2
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import"../index-m38ej7e5.js";
|
|
2
2
|
import"../index-q46b16xz.js";
|
|
3
3
|
import"../index-yrhw10ef.js";
|
|
4
|
-
import"../index-
|
|
4
|
+
import"../index-d01akj5n.js";
|
|
5
5
|
import {
|
|
6
6
|
endpointHasArguments,
|
|
7
7
|
createClient2
|
|
8
|
-
} from "../index-
|
|
8
|
+
} from "../index-6f4fjygr.js";
|
|
9
9
|
import"../index-yt1gg11x.js";
|
|
10
10
|
import {
|
|
11
11
|
contractMethodFields,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "../index-m38ej7e5.js";
|
|
4
4
|
import"../index-q46b16xz.js";
|
|
5
5
|
import"../index-yrhw10ef.js";
|
|
6
|
-
import"../index-
|
|
6
|
+
import"../index-d01akj5n.js";
|
|
7
7
|
import {
|
|
8
8
|
createClient2,
|
|
9
9
|
createClients2
|
|
10
|
-
} from "../index-
|
|
10
|
+
} from "../index-6f4fjygr.js";
|
|
11
11
|
import"../index-5xsxvk2x.js";
|
|
12
12
|
import {
|
|
13
13
|
createApplication2
|
|
@@ -14,11 +14,15 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
utf8ByteLength
|
|
16
16
|
} from "./index-f16b7rze.js";
|
|
17
|
+
import {
|
|
18
|
+
assertNonNegativeSafeInteger
|
|
19
|
+
} from "./index-gr0kxymw.js";
|
|
17
20
|
import {
|
|
18
21
|
assertTimerMs
|
|
19
22
|
} from "./index-e1y74yra.js";
|
|
20
23
|
import {
|
|
21
24
|
abortReason,
|
|
25
|
+
untilAborted,
|
|
22
26
|
linkAbortSignals
|
|
23
27
|
} from "./index-rptj3qnc.js";
|
|
24
28
|
import {
|
|
@@ -30,6 +34,87 @@ import {
|
|
|
30
34
|
} from "./index-ps3djm8d.js";
|
|
31
35
|
|
|
32
36
|
// src/browser/http-fetch.ts
|
|
37
|
+
function buildMaterializedInit(input, init, headers, signal, body, unix) {
|
|
38
|
+
const materialized = {
|
|
39
|
+
...init,
|
|
40
|
+
...unix !== undefined && { unix },
|
|
41
|
+
method: init?.method ?? input.method,
|
|
42
|
+
headers,
|
|
43
|
+
...body !== undefined && { body },
|
|
44
|
+
cache: init?.cache ?? input.cache,
|
|
45
|
+
credentials: init?.credentials ?? input.credentials,
|
|
46
|
+
integrity: init?.integrity ?? input.integrity,
|
|
47
|
+
keepalive: init?.keepalive ?? input.keepalive,
|
|
48
|
+
mode: init?.mode ?? input.mode,
|
|
49
|
+
redirect: init?.redirect ?? input.redirect,
|
|
50
|
+
referrer: init?.referrer ?? input.referrer,
|
|
51
|
+
referrerPolicy: init?.referrerPolicy ?? input.referrerPolicy,
|
|
52
|
+
...signal !== undefined && { signal }
|
|
53
|
+
};
|
|
54
|
+
if (init?.body === undefined && "duplex" in materialized) {
|
|
55
|
+
Reflect.deleteProperty(materialized, "duplex");
|
|
56
|
+
}
|
|
57
|
+
return materialized;
|
|
58
|
+
}
|
|
59
|
+
function concatChunks(chunks, totalBytes) {
|
|
60
|
+
if (totalBytes === 0)
|
|
61
|
+
return new ArrayBuffer(0);
|
|
62
|
+
if (chunks.length === 1) {
|
|
63
|
+
const [only] = chunks;
|
|
64
|
+
if (only) {
|
|
65
|
+
if (only.byteOffset === 0 && only.byteLength === only.buffer.byteLength && only.buffer instanceof ArrayBuffer) {
|
|
66
|
+
return only.buffer;
|
|
67
|
+
}
|
|
68
|
+
return only.slice().buffer;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const merged = new Uint8Array(totalBytes);
|
|
72
|
+
let offset = 0;
|
|
73
|
+
for (const chunk of chunks) {
|
|
74
|
+
merged.set(chunk, offset);
|
|
75
|
+
offset += chunk.byteLength;
|
|
76
|
+
}
|
|
77
|
+
return merged.buffer;
|
|
78
|
+
}
|
|
79
|
+
async function readRequestBodyBytes(input, signal) {
|
|
80
|
+
if (!signal || !input.body)
|
|
81
|
+
return input.arrayBuffer();
|
|
82
|
+
const reader = input.body.getReader();
|
|
83
|
+
const chunks = [];
|
|
84
|
+
let totalBytes = 0;
|
|
85
|
+
let cancelled = false;
|
|
86
|
+
try {
|
|
87
|
+
for (;; ) {
|
|
88
|
+
const outcome = await untilAborted(reader.read(), signal);
|
|
89
|
+
if (outcome.aborted) {
|
|
90
|
+
cancelled = true;
|
|
91
|
+
reader.cancel(abortReason(signal)).catch(() => {
|
|
92
|
+
return;
|
|
93
|
+
}).finally(() => {
|
|
94
|
+
try {
|
|
95
|
+
reader.releaseLock();
|
|
96
|
+
} catch {}
|
|
97
|
+
});
|
|
98
|
+
throw abortReason(signal);
|
|
99
|
+
}
|
|
100
|
+
if (outcome.value.done)
|
|
101
|
+
return concatChunks(chunks, totalBytes);
|
|
102
|
+
chunks.push(outcome.value.value);
|
|
103
|
+
totalBytes += outcome.value.value.byteLength;
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
if (!cancelled) {
|
|
107
|
+
try {
|
|
108
|
+
reader.releaseLock();
|
|
109
|
+
} catch {}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function dispatchMaterializedBody(runtimeFetch, input, init, signal, unix) {
|
|
114
|
+
const headers = init?.headers !== undefined ? new Headers(init.headers) : new Headers(input.headers);
|
|
115
|
+
const body = await readRequestBodyBytes(input, signal);
|
|
116
|
+
return runtimeFetch(input.url, buildMaterializedInit(input, init, headers, signal, body, unix));
|
|
117
|
+
}
|
|
33
118
|
function createRetryAwareFetch(transportFetch, unix) {
|
|
34
119
|
const runtimeFetch = transportFetch;
|
|
35
120
|
let attempt = 0;
|
|
@@ -44,24 +129,15 @@ function createRetryAwareFetch(transportFetch, unix) {
|
|
|
44
129
|
const unixInit = { ...init, unix };
|
|
45
130
|
return runtimeFetch(input, unixInit);
|
|
46
131
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
integrity: input.integrity,
|
|
57
|
-
keepalive: input.keepalive,
|
|
58
|
-
mode: input.mode,
|
|
59
|
-
redirect: input.redirect,
|
|
60
|
-
referrer: input.referrer,
|
|
61
|
-
referrerPolicy: input.referrerPolicy,
|
|
62
|
-
signal: input.signal
|
|
63
|
-
};
|
|
64
|
-
return runtimeFetch(input.url, materialized);
|
|
132
|
+
if (unix === undefined && input.body === undefined) {
|
|
133
|
+
return runtimeFetch(input, init);
|
|
134
|
+
}
|
|
135
|
+
const signal = init?.signal !== undefined ? init.signal : input.signal;
|
|
136
|
+
if (init?.body === undefined && input.body !== null && input.body !== undefined && !signal?.aborted) {
|
|
137
|
+
return dispatchMaterializedBody(runtimeFetch, input, init, signal, unix);
|
|
138
|
+
}
|
|
139
|
+
const headers = init?.headers !== undefined ? new Headers(init.headers) : new Headers(input.headers);
|
|
140
|
+
return runtimeFetch(input.url, buildMaterializedInit(input, init, headers, signal, undefined, unix));
|
|
65
141
|
};
|
|
66
142
|
}
|
|
67
143
|
function searchParamsOf(params) {
|
|
@@ -220,6 +296,37 @@ function responseTraceId(response) {
|
|
|
220
296
|
}
|
|
221
297
|
|
|
222
298
|
// src/browser/http-helpers.ts
|
|
299
|
+
var DEFAULT_RETRY_METHODS = ["get", "head"];
|
|
300
|
+
function normalizeClientRetryConfig(retry) {
|
|
301
|
+
if (retry !== undefined && (typeof retry !== "object" || retry === null || Array.isArray(retry))) {
|
|
302
|
+
throw new TypeError("HttpClientConfig.retry must be an object");
|
|
303
|
+
}
|
|
304
|
+
assertNonNegativeSafeInteger("HttpClientConfig.retry.limit", retry?.limit);
|
|
305
|
+
const limit = retry?.limit ?? 2;
|
|
306
|
+
const rawMethods = retry?.methods ?? DEFAULT_RETRY_METHODS;
|
|
307
|
+
if (!Array.isArray(rawMethods) || !rawMethods.every((entry) => typeof entry === "string")) {
|
|
308
|
+
throw new TypeError("HttpClientConfig.retry.methods must be an array of strings");
|
|
309
|
+
}
|
|
310
|
+
const methods = rawMethods.map((entry) => entry.toLowerCase());
|
|
311
|
+
const rawStatusCodes = retry?.statusCodes ?? [];
|
|
312
|
+
if (!Array.isArray(rawStatusCodes) || !rawStatusCodes.every((code) => Number.isSafeInteger(code))) {
|
|
313
|
+
throw new TypeError("HttpClientConfig.retry.statusCodes must be an array of integers");
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
limit,
|
|
317
|
+
methods,
|
|
318
|
+
methodSet: new Set(methods),
|
|
319
|
+
statusCodes: [...rawStatusCodes]
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
function resolveCallRetry(retry, method, idempotent) {
|
|
323
|
+
const methodRetries = idempotent ?? retry.methodSet.has(method);
|
|
324
|
+
if (!methodRetries)
|
|
325
|
+
return { limit: 0 };
|
|
326
|
+
if (idempotent === true)
|
|
327
|
+
return { methods: [method] };
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
223
330
|
function assertTransportChoice(config) {
|
|
224
331
|
if (config.fetch && config.unix) {
|
|
225
332
|
throw new TypeError("HttpClientConfig.fetch and unix are mutually exclusive");
|
|
@@ -564,6 +671,7 @@ function resolveOutboundDeadlineAt(options, config, effectiveTimeoutMs) {
|
|
|
564
671
|
function createHttpClient2(config) {
|
|
565
672
|
assertTransportChoice(config);
|
|
566
673
|
assertTimerMs("HTTP client timeout", config.timeout);
|
|
674
|
+
const retryConfig = normalizeClientRetryConfig(config.retry);
|
|
567
675
|
let ssrCookies = null;
|
|
568
676
|
let isLoggedOut = false;
|
|
569
677
|
const listeners = new Set;
|
|
@@ -581,9 +689,9 @@ function createHttpClient2(config) {
|
|
|
581
689
|
credentials: config.credentials ?? "include",
|
|
582
690
|
timeout: false,
|
|
583
691
|
retry: {
|
|
584
|
-
limit:
|
|
585
|
-
methods:
|
|
586
|
-
statusCodes:
|
|
692
|
+
limit: retryConfig.limit,
|
|
693
|
+
methods: [...retryConfig.methods],
|
|
694
|
+
statusCodes: [...retryConfig.statusCodes],
|
|
587
695
|
shouldRetry: ({ error }) => shouldRetryBunNetworkError(error)
|
|
588
696
|
},
|
|
589
697
|
hooks: {
|
|
@@ -653,20 +761,21 @@ function createHttpClient2(config) {
|
|
|
653
761
|
throw cause;
|
|
654
762
|
});
|
|
655
763
|
};
|
|
764
|
+
const isFormData = typeof FormData === "function" && data instanceof FormData;
|
|
765
|
+
const callRetry = resolveCallRetry(retryConfig, method, options.idempotent);
|
|
656
766
|
const kyOptions = {
|
|
657
767
|
fetch: createRetryAwareFetch(options.onUploadProgress ? withUploadProgress(transport, options.onUploadProgress, {
|
|
658
768
|
route: uploadProgressRoute(config.fetch !== undefined || config.unix !== undefined),
|
|
659
|
-
nativeBody:
|
|
769
|
+
nativeBody: isFormData ? data : jsonBodyOf(data),
|
|
660
770
|
responseType: options.responseType
|
|
661
771
|
}) : transport, config.unix),
|
|
662
772
|
timeout: false,
|
|
663
|
-
...
|
|
664
|
-
...options.idempotent === false && { retry: { limit: 0 } }
|
|
773
|
+
...callRetry !== undefined && { retry: callRetry }
|
|
665
774
|
};
|
|
666
775
|
const searchParams = options.params ? searchParamsOf(options.params) : undefined;
|
|
667
776
|
if (searchParams)
|
|
668
777
|
kyOptions.searchParams = searchParams;
|
|
669
|
-
if (
|
|
778
|
+
if (isFormData) {
|
|
670
779
|
kyOptions.body = data;
|
|
671
780
|
} else if (data !== undefined) {
|
|
672
781
|
kyOptions.json = data;
|
package/llms/stitchkit.txt
CHANGED
|
@@ -519,5 +519,13 @@ StitchKit passes that retry's current `Request.signal` in the second fetch
|
|
|
519
519
|
argument and materializes the current Request as URL + init. Next 16.3 otherwise
|
|
520
520
|
merges `init` into a Request before its dedupe layer and loses the explicit
|
|
521
521
|
signal opt-out. The retry therefore performs a new network attempt instead of
|
|
522
|
-
returning the cached rejection.
|
|
523
|
-
|
|
522
|
+
returning the cached rejection. When a retried request carries a body (for
|
|
523
|
+
example an `idempotent: true` `POST` or `PUT` with JSON or `FormData`),
|
|
524
|
+
StitchKit copies its headers and buffers the body into concrete `ArrayBuffer`
|
|
525
|
+
bytes instead of forwarding `Request.body` as a `ReadableStream` with
|
|
526
|
+
`duplex: 'half'`, so browser HTTP/1.1 transports (Chromium, WebKit) deliver the
|
|
527
|
+
retry intact. Calls whose method is not retried pass `retry: { limit: 0 }` so Ky
|
|
528
|
+
does not clone the `Request`, keeping the body as direct bytes in browser
|
|
529
|
+
DevTools Protocol and Playwright `request.postData()`. This adapter does not broaden retry policy: POST,
|
|
530
|
+
unconfigured HTTP statuses, cancellation and exhausted budgets retain the rules
|
|
531
|
+
above.
|
package/llms-full.txt
CHANGED
|
@@ -3367,8 +3367,16 @@ StitchKit passes that retry's current `Request.signal` in the second fetch
|
|
|
3367
3367
|
argument and materializes the current Request as URL + init. Next 16.3 otherwise
|
|
3368
3368
|
merges `init` into a Request before its dedupe layer and loses the explicit
|
|
3369
3369
|
signal opt-out. The retry therefore performs a new network attempt instead of
|
|
3370
|
-
returning the cached rejection.
|
|
3371
|
-
|
|
3370
|
+
returning the cached rejection. When a retried request carries a body (for
|
|
3371
|
+
example an `idempotent: true` `POST` or `PUT` with JSON or `FormData`),
|
|
3372
|
+
StitchKit copies its headers and buffers the body into concrete `ArrayBuffer`
|
|
3373
|
+
bytes instead of forwarding `Request.body` as a `ReadableStream` with
|
|
3374
|
+
`duplex: 'half'`, so browser HTTP/1.1 transports (Chromium, WebKit) deliver the
|
|
3375
|
+
retry intact. Calls whose method is not retried pass `retry: { limit: 0 }` so Ky
|
|
3376
|
+
does not clone the `Request`, keeping the body as direct bytes in browser
|
|
3377
|
+
DevTools Protocol and Playwright `request.postData()`. This adapter does not broaden retry policy: POST,
|
|
3378
|
+
unconfigured HTTP statuses, cancellation and exhausted budgets retain the rules
|
|
3379
|
+
above.
|
|
3372
3380
|
|
|
3373
3381
|
## `createClient`
|
|
3374
3382
|
|
package/llms.txt
CHANGED
|
@@ -9,7 +9,7 @@ Build with stitchkit: define a contract once, then `implement` it and serve it (
|
|
|
9
9
|
Load the slice for each entrypoint your code imports — `import … from 'stitchkit/server'` → `llms/server.txt`; the root `stitchkit` import → `llms/stitchkit.txt`. A slice holds that entrypoint's API reference section and the guide pages whose home it is; every guide lives in exactly one slice, and a slice that needs another's guide names it under "Also read". Each file is at most 50.0 KB; a longer one continues in numbered parts, each naming the next at its top. Moving across versions: load `llms/upgrading.txt` and the range slices it lists between your version and the target. `llms-full.txt` inlines everything; it is far larger than a context window, so do not read it whole.
|
|
10
10
|
|
|
11
11
|
## Entrypoint slices
|
|
12
|
-
- **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt)
|
|
12
|
+
- **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt) 44.4 KB → [llms/stitchkit.2.txt](llms/stitchkit.2.txt) 47.2 KB → [llms/stitchkit.3.txt](llms/stitchkit.3.txt) 29.4 KB
|
|
13
13
|
- **stitchkit/live**: [llms/live.txt](llms/live.txt) 22.9 KB
|
|
14
14
|
- **stitchkit/react**: [llms/react.txt](llms/react.txt) 8.7 KB
|
|
15
15
|
- **stitchkit/react/keyboard**: [llms/react-keyboard.txt](llms/react-keyboard.txt) 22.7 KB
|
package/package.json
CHANGED