You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add retry feature documentation and examples
- Add automatic retry feature to README.md and README.cn.md
- Create examples/with-retry.ts with 8 comprehensive retry examples
- Update CODEBUDDY.md with retry mechanism, stream response type,
updated dependency versions, and 12 function overloads
- Add retry example link to examples list in both READMEs
- Import with-retry.ts in examples/main.ts
- Shared controller for both timeout and manual abort
311
-
- Timeout abort passes custom Error with `name: TIMEOUT_ERROR`
312
-
- Manual abort can pass any reason value
324
+
- User abort controller created only when `abortable: true`
325
+
- Timeout uses native `AbortSignal.timeout()` API
326
+
- Multiple signals combined via `AbortSignal.any()`
327
+
- Manual abort wraps non-Error reasons in Error with `name: ABORT_ERROR`
313
328
- Signal is added to fetch `RequestInit` automatically
314
-
- Controller only created when needed (`abortable: true` or `timeout` specified)
315
329
316
330
## Publishing
317
331
@@ -335,7 +349,7 @@ The `prepublishOnly` script automatically runs `pnpm run build`, which includes:
335
349
336
350
## Known Issues & Gotchas
337
351
338
-
1.**Progress tracking requires Content-Length header**: If the server doesn't send this header, progress tracking will fail (onProgress receives an Err). The code checks both `content-length` and `Content-Length` for HTTP/2 compatibility.
352
+
1.**Progress tracking requires Content-Length header**: If the server doesn't send this header, progress tracking will fail (onProgress receives an Err). The `Headers.get()` method is case-insensitive per the HTTP spec.
339
353
340
354
2.**Stream tee() limitation**: Progress/chunk callbacks add overhead due to stream splitting. Each chunk is read twice - once for tracking, once for parsing.
341
355
@@ -345,11 +359,13 @@ The `prepublishOnly` script automatically runs `pnpm run build`, which includes:
345
359
346
360
5.**happy-rusty Result API**: Use `isOk()`, `isErr()`, `unwrap()`, `unwrapErr()` methods. Note that `match()` method does NOT exist in happy-rusty.
347
361
362
+
6.**Retry behavior**: By default, only network errors trigger retries. HTTP errors (4xx, 5xx) require explicit configuration via the `when` option in `FetchRetryOptions`.
363
+
348
364
## Key Files Reference
349
365
350
366
### Source Code
351
367
-`src/mod.ts` - Main entry point (re-exports from fetch/)
352
-
-`src/fetch/fetch.ts` - Core fetchT implementation function with 10 overloads
368
+
-`src/fetch/fetch.ts` - Core fetchT implementation function with 12 overloads
353
369
-`src/fetch/defines.ts` - All type definitions (FetchTask, FetchInit, FetchError, etc.)
0 commit comments