@ai-sdk/gateway 4.0.129 → 4.0.130

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ai-sdk/gateway",
3
3
  "private": false,
4
- "version": "4.0.129",
4
+ "version": "4.0.130",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "sideEffects": false,
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@ai-sdk/provider": "4.0.34",
34
- "@ai-sdk/provider-utils": "5.0.70",
34
+ "@ai-sdk/provider-utils": "5.0.71",
35
35
  "@vercel/oidc": "3.2.0"
36
36
  },
37
37
  "devDependencies": {
@@ -31,6 +31,15 @@ export async function asGatewayError(
31
31
  error: unknown,
32
32
  authMethod?: 'api-key' | 'oidc',
33
33
  ) {
34
+ // Caller cancellation is not a gateway failure and must not become a retryable 500.
35
+ if (
36
+ (error instanceof Error ||
37
+ (typeof DOMException === 'function' && error instanceof DOMException)) &&
38
+ (error.name === 'AbortError' || error.name === 'TimeoutError')
39
+ ) {
40
+ throw error;
41
+ }
42
+
34
43
  if (GatewayError.isInstance(error)) {
35
44
  return error;
36
45
  }
@@ -10,7 +10,10 @@ export async function errorControllerWithGatewayError<PART>(
10
10
  error: unknown,
11
11
  authMethod: 'api-key' | 'oidc' | undefined,
12
12
  ): Promise<void> {
13
- controller.error(await asGatewayError(error, authMethod));
13
+ // Cancellation errors are rethrown by asGatewayError and must still reach the stream.
14
+ controller.error(
15
+ await asGatewayError(error, authMethod).catch(error => error),
16
+ );
14
17
  }
15
18
 
16
19
  /**