@mastra/react 1.2.3-alpha.2 → 1.2.3-alpha.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 +18 -0
- package/dist/agent/hooks.d.ts.map +1 -1
- package/dist/index.cjs +20 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2067,6 +2067,13 @@ var useChat = ({
|
|
|
2067
2067
|
const subscriptionAbort = new AbortController();
|
|
2068
2068
|
_threadSubscriptionAbortRef.current = subscriptionAbort;
|
|
2069
2069
|
_threadSubscriptionKeyRef.current = subscriptionKey;
|
|
2070
|
+
const releaseSubscriptionRefs = () => {
|
|
2071
|
+
if (_threadSubscriptionAbortRef.current !== subscriptionAbort) return;
|
|
2072
|
+
_threadSubscriptionRef.current = null;
|
|
2073
|
+
_threadSubscriptionAbortRef.current = null;
|
|
2074
|
+
_threadSubscriptionKeyRef.current = void 0;
|
|
2075
|
+
_threadSubscriptionPromiseRef.current = null;
|
|
2076
|
+
};
|
|
2070
2077
|
const clientWithAbort = new MastraClient({
|
|
2071
2078
|
...baseClient.options,
|
|
2072
2079
|
abortSignal: subscriptionAbort.signal
|
|
@@ -2090,21 +2097,12 @@ var useChat = ({
|
|
|
2090
2097
|
if (_threadSubscriptionRef.current === subscription) {
|
|
2091
2098
|
_threadSubscriptionRef.current = null;
|
|
2092
2099
|
}
|
|
2093
|
-
|
|
2094
|
-
_threadSubscriptionAbortRef.current = null;
|
|
2095
|
-
_threadSubscriptionKeyRef.current = void 0;
|
|
2096
|
-
_threadSubscriptionPromiseRef.current = null;
|
|
2097
|
-
}
|
|
2100
|
+
releaseSubscriptionRefs();
|
|
2098
2101
|
});
|
|
2099
2102
|
}).catch((error) => {
|
|
2103
|
+
releaseSubscriptionRefs();
|
|
2100
2104
|
if (isThreadSignalUnsupportedError(error)) {
|
|
2101
2105
|
markThreadSignalsUnsupported();
|
|
2102
|
-
if (_threadSubscriptionAbortRef.current === subscriptionAbort) {
|
|
2103
|
-
_threadSubscriptionRef.current = null;
|
|
2104
|
-
_threadSubscriptionAbortRef.current = null;
|
|
2105
|
-
_threadSubscriptionKeyRef.current = void 0;
|
|
2106
|
-
_threadSubscriptionPromiseRef.current = null;
|
|
2107
|
-
}
|
|
2108
2106
|
return;
|
|
2109
2107
|
}
|
|
2110
2108
|
if (!isAbortError(error)) {
|
|
@@ -2641,12 +2639,17 @@ var useChat = ({
|
|
|
2641
2639
|
} else {
|
|
2642
2640
|
setMessages((s) => [...s, dbUserMessage]);
|
|
2643
2641
|
}
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2642
|
+
try {
|
|
2643
|
+
if (mode === "generate") {
|
|
2644
|
+
await generate({ ...args, coreUserMessages });
|
|
2645
|
+
} else if (mode === "stream") {
|
|
2646
|
+
await stream({ ...args, coreUserMessages, signalId, clientMessageId });
|
|
2647
|
+
} else if (mode === "network") {
|
|
2648
|
+
await network({ ...args, coreUserMessages });
|
|
2649
|
+
}
|
|
2650
|
+
} catch (error) {
|
|
2651
|
+
setIsRunning(false);
|
|
2652
|
+
throw error;
|
|
2650
2653
|
}
|
|
2651
2654
|
};
|
|
2652
2655
|
return {
|