ai 5.0.260 → 5.0.261

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/dist/index.mjs CHANGED
@@ -727,7 +727,7 @@ import {
727
727
  } from "@ai-sdk/provider-utils";
728
728
 
729
729
  // src/version.ts
730
- var VERSION = true ? "5.0.260" : "0.0.0-test";
730
+ var VERSION = true ? "5.0.261" : "0.0.0-test";
731
731
 
732
732
  // src/util/download/download.ts
733
733
  var download = async ({
@@ -10658,9 +10658,15 @@ function readUIMessageStream({
10658
10658
  var _a16;
10659
10659
  let controller;
10660
10660
  let hasErrored = false;
10661
+ let isCancelled = false;
10662
+ const abortController = new AbortController();
10661
10663
  const outputStream = new ReadableStream({
10662
10664
  start(controllerParam) {
10663
10665
  controller = controllerParam;
10666
+ },
10667
+ cancel() {
10668
+ isCancelled = true;
10669
+ abortController.abort();
10664
10670
  }
10665
10671
  });
10666
10672
  const state = createStreamingUIMessageState({
@@ -10681,15 +10687,18 @@ function readUIMessageStream({
10681
10687
  return job({
10682
10688
  state,
10683
10689
  write: () => {
10684
- controller == null ? void 0 : controller.enqueue(createUIMessageSnapshot(state.message));
10690
+ if (!isCancelled) {
10691
+ controller == null ? void 0 : controller.enqueue(createUIMessageSnapshot(state.message));
10692
+ }
10685
10693
  }
10686
10694
  });
10687
10695
  },
10688
10696
  onError: handleError
10689
10697
  }),
10690
- onError: handleError
10698
+ onError: handleError,
10699
+ abortSignal: abortController.signal
10691
10700
  }).finally(() => {
10692
- if (!hasErrored) {
10701
+ if (!hasErrored && !isCancelled) {
10693
10702
  controller == null ? void 0 : controller.close();
10694
10703
  }
10695
10704
  });