@ai-sdk/provider-utils 3.0.13 → 3.0.15

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 3.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - f2da310: chore(provider-utils): upgrade eventsource-parser to 3.0.6
8
+
9
+ ## 3.0.14
10
+
11
+ ### Patch Changes
12
+
13
+ - 949718b: fix(provider-utils): make ReadableStream.cancel() properly finalize async iterators
14
+
3
15
  ## 3.0.13
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -103,6 +103,7 @@ function combineHeaders(...headers) {
103
103
 
104
104
  // src/convert-async-iterator-to-readable-stream.ts
105
105
  function convertAsyncIteratorToReadableStream(iterator) {
106
+ let cancelled = false;
106
107
  return new ReadableStream({
107
108
  /**
108
109
  * Called when the consumer wants to pull more data from the stream.
@@ -111,6 +112,7 @@ function convertAsyncIteratorToReadableStream(iterator) {
111
112
  * @returns {Promise<void>}
112
113
  */
113
114
  async pull(controller) {
115
+ if (cancelled) return;
114
116
  try {
115
117
  const { value, done } = await iterator.next();
116
118
  if (done) {
@@ -125,7 +127,14 @@ function convertAsyncIteratorToReadableStream(iterator) {
125
127
  /**
126
128
  * Called when the consumer cancels the stream.
127
129
  */
128
- cancel() {
130
+ async cancel(reason) {
131
+ cancelled = true;
132
+ if (iterator.return) {
133
+ try {
134
+ await iterator.return(reason);
135
+ } catch (e) {
136
+ }
137
+ }
129
138
  }
130
139
  });
131
140
  }
@@ -299,7 +308,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
299
308
  }
300
309
 
301
310
  // src/version.ts
302
- var VERSION = true ? "3.0.13" : "0.0.0-test";
311
+ var VERSION = true ? "3.0.15" : "0.0.0-test";
303
312
 
304
313
  // src/get-from-api.ts
305
314
  var getOriginalFetch = () => globalThis.fetch;