Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai-client): export StreamHttpError from ai-client and framework packages #2258

Opendarkobits(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/2258/headopened View on GitHub

Showing 13 changed files with 16 additions and 1 deletion (loading 10).

x
0 of 13 viewed, 13 left
13 additions and 0 deletions.changeset/export-stream-http-error.mdAdded
View file
@@ -0,0 +1,13 @@
+---
+'@tanstack/ai-client': minor
+'@tanstack/ai-react': minor
+'@tanstack/ai-solid': minor
+'@tanstack/ai-preact': minor
+'@tanstack/ai-vue': minor
+'@tanstack/ai-octane': minor
+'@tanstack/ai-remix': minor
+'@tanstack/ai-svelte': minor
+'@tanstack/ai-angular': minor
+---
+​
+Export `StreamHttpError` from `@tanstack/ai-client` and re-export it from the framework packages (`@tanstack/ai-react`, `@tanstack/ai-solid`, `@tanstack/ai-preact`, `@tanstack/ai-vue`, `@tanstack/ai-octane`, `@tanstack/ai-remix`, `@tanstack/ai-svelte`, `@tanstack/ai-angular`). A failed HTTP stream connect throws this class, which has `status` and `retryAfterMs`. Import it to check the status with `instanceof` instead of parsing the error message.
2 additions and 0 deletionsdocs/transports/overview.mdModified
View file
@@ -152,6 +152,8 @@
​
If the connection drops in the middle of a line, the stream transports throw `StreamTruncatedError`.
​
+A failed HTTP response can throw `StreamHttpError`. It has a `status` property with the HTTP status code, and a `retryAfterMs` property with the `Retry-After` delay in milliseconds. Import it from `@tanstack/ai-client`, or from your framework package, such as `@tanstack/ai-react`.
+​
In a custom transport, do not catch and hide an `AbortError`. Let it propagate, so that the client knows that the abort worked.
​
### Rules for a custom transport
1 addition and 1 deletiondocs/config.jsonModified
View file
@@ -288,7 +288,7 @@