@ai-sdk/react
Advanced tools
Comparing version 0.0.14 to 0.0.15
# @ai-sdk/react | ||
## 0.0.15 | ||
### Patch Changes | ||
- 6c99581e: fix (ai/react): stop() on useObject does not throw error and clears isLoading | ||
## 0.0.14 | ||
@@ -4,0 +10,0 @@ |
@@ -702,2 +702,3 @@ "use strict"; | ||
// src/use-object.ts | ||
var import_provider_utils2 = require("@ai-sdk/provider-utils"); | ||
var import_ui_utils4 = require("@ai-sdk/ui-utils"); | ||
@@ -727,4 +728,9 @@ var import_react4 = require("react"); | ||
var _a; | ||
(_a = abortControllerRef.current) == null ? void 0 : _a.abort(); | ||
abortControllerRef.current = null; | ||
try { | ||
(_a = abortControllerRef.current) == null ? void 0 : _a.abort(); | ||
} catch (ignored) { | ||
} finally { | ||
setIsLoading(false); | ||
abortControllerRef.current = null; | ||
} | ||
}, []); | ||
@@ -735,2 +741,3 @@ const submit = async (input) => { | ||
setIsLoading(true); | ||
setError(void 0); | ||
const abortController = new AbortController(); | ||
@@ -755,3 +762,3 @@ abortControllerRef.current = abortController; | ||
let latestObject = void 0; | ||
response.body.pipeThrough(new TextDecoderStream()).pipeTo( | ||
await response.body.pipeThrough(new TextDecoderStream()).pipeTo( | ||
new WritableStream({ | ||
@@ -774,4 +781,6 @@ write(chunk) { | ||
); | ||
setError(void 0); | ||
} catch (error2) { | ||
if ((0, import_provider_utils2.isAbortError)(error2)) { | ||
return; | ||
} | ||
setError(error2); | ||
@@ -778,0 +787,0 @@ } |
{ | ||
"name": "@ai-sdk/react", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -0,1 +1,2 @@ | ||
import { isAbortError } from '@ai-sdk/provider-utils'; | ||
import { | ||
@@ -104,4 +105,9 @@ DeepPartial, | ||
const stop = useCallback(() => { | ||
abortControllerRef.current?.abort(); | ||
abortControllerRef.current = null; | ||
try { | ||
abortControllerRef.current?.abort(); | ||
} catch (ignored) { | ||
} finally { | ||
setIsLoading(false); | ||
abortControllerRef.current = null; | ||
} | ||
}, []); | ||
@@ -112,2 +118,3 @@ | ||
setIsLoading(true); | ||
setError(undefined); | ||
@@ -138,3 +145,3 @@ const abortController = new AbortController(); | ||
response.body.pipeThrough(new TextDecoderStream()).pipeTo( | ||
await response.body.pipeThrough(new TextDecoderStream()).pipeTo( | ||
new WritableStream<string>({ | ||
@@ -161,5 +168,7 @@ write(chunk) { | ||
); | ||
} catch (error) { | ||
if (isAbortError(error)) { | ||
return; | ||
} | ||
setError(undefined); | ||
} catch (error) { | ||
setError(error); | ||
@@ -166,0 +175,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
235618
3850