@boatdev/sdk 1.9.8 → 1.9.9

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.
@@ -168,28 +168,36 @@ async function http2Fetch(input, init = {}) {
168
168
  // turned that into "Premature close" on 25 of 250 calls (prod, 2026-10-08).
169
169
  // A slow reader (streamCommand between frames) must not let a fast command
170
170
  // fill memory: past 4 MiB unread the stream pauses until the reader pulls.
171
+ // A reader that cancels (it stopped early) closes the body; data, 'end' or
172
+ // 'error' still in flight must then do nothing. Calling close() on it threw
173
+ // from an event handler and killed the process (prod, 2026-10-14).
174
+ let open = true;
175
+ const finish = (settle) => {
176
+ if (!open)
177
+ return;
178
+ open = false;
179
+ settle();
180
+ };
171
181
  const bodyStream = empty ? null : new ReadableStream({
172
182
  start(controller) {
173
183
  req.on('data', (chunk) => {
174
184
  var _a;
185
+ if (!open)
186
+ return;
175
187
  controller.enqueue(new Uint8Array(chunk));
176
188
  if (((_a = controller.desiredSize) !== null && _a !== void 0 ? _a : 1) <= 0)
177
189
  req.pause();
178
190
  });
179
- req.once('end', () => controller.close());
180
- req.once('error', (e) => controller.error(e));
191
+ req.once('end', () => finish(() => controller.close()));
192
+ req.once('error', (e) => finish(() => controller.error(e)));
181
193
  req.once('close', () => {
182
- if (!req.readableEnded) {
183
- try {
184
- controller.error(new Error(`HTTP/2 stream closed before its end (code ${req.rstCode})`));
185
- }
186
- catch (_a) { }
187
- }
194
+ if (!req.readableEnded)
195
+ finish(() => controller.error(new Error(`HTTP/2 stream closed before its end (code ${req.rstCode})`)));
188
196
  });
189
197
  },
190
198
  pull() { if (req.isPaused())
191
199
  req.resume(); },
192
- cancel() { req.close(); },
200
+ cancel() { open = false; req.close(); },
193
201
  }, { highWaterMark: 4 * 1024 * 1024, size: (chunk) => { var _a; return (_a = chunk === null || chunk === void 0 ? void 0 : chunk.byteLength) !== null && _a !== void 0 ? _a : 0; } });
194
202
  const response = new Response(bodyStream, { status, headers: out });
195
203
  // Response.url is read-only; the generated client never reads it, but keep it right.
@@ -204,28 +204,36 @@ async function http2Fetch(input, init = {}) {
204
204
  // turned that into "Premature close" on 25 of 250 calls (prod, 2026-10-08).
205
205
  // A slow reader (streamCommand between frames) must not let a fast command
206
206
  // fill memory: past 4 MiB unread the stream pauses until the reader pulls.
207
+ // A reader that cancels (it stopped early) closes the body; data, 'end' or
208
+ // 'error' still in flight must then do nothing. Calling close() on it threw
209
+ // from an event handler and killed the process (prod, 2026-10-14).
210
+ let open = true;
211
+ const finish = (settle) => {
212
+ if (!open)
213
+ return;
214
+ open = false;
215
+ settle();
216
+ };
207
217
  const bodyStream = empty ? null : new ReadableStream({
208
218
  start(controller) {
209
219
  req.on('data', (chunk) => {
210
220
  var _a;
221
+ if (!open)
222
+ return;
211
223
  controller.enqueue(new Uint8Array(chunk));
212
224
  if (((_a = controller.desiredSize) !== null && _a !== void 0 ? _a : 1) <= 0)
213
225
  req.pause();
214
226
  });
215
- req.once('end', () => controller.close());
216
- req.once('error', (e) => controller.error(e));
227
+ req.once('end', () => finish(() => controller.close()));
228
+ req.once('error', (e) => finish(() => controller.error(e)));
217
229
  req.once('close', () => {
218
- if (!req.readableEnded) {
219
- try {
220
- controller.error(new Error(`HTTP/2 stream closed before its end (code ${req.rstCode})`));
221
- }
222
- catch (_a) { }
223
- }
230
+ if (!req.readableEnded)
231
+ finish(() => controller.error(new Error(`HTTP/2 stream closed before its end (code ${req.rstCode})`)));
224
232
  });
225
233
  },
226
234
  pull() { if (req.isPaused())
227
235
  req.resume(); },
228
- cancel() { req.close(); },
236
+ cancel() { open = false; req.close(); },
229
237
  }, { highWaterMark: 4 * 1024 * 1024, size: (chunk) => { var _a; return (_a = chunk === null || chunk === void 0 ? void 0 : chunk.byteLength) !== null && _a !== void 0 ? _a : 0; } });
230
238
  const response = new Response(bodyStream, { status, headers: out });
231
239
  // Response.url is read-only; the generated client never reads it, but keep it right.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boatdev/sdk",
3
- "version": "1.9.8",
3
+ "version": "1.9.9",
4
4
  "description": "OpenAPI client for @boatdev/sdk",
5
5
  "author": "OpenAPI-Generator",
6
6
  "license": "MIT",
@@ -152,20 +152,30 @@ async function http2Fetch(input: RequestInfo | URL, init: RequestInit = {}): Pro
152
152
  // turned that into "Premature close" on 25 of 250 calls (prod, 2026-10-08).
153
153
  // A slow reader (streamCommand between frames) must not let a fast command
154
154
  // fill memory: past 4 MiB unread the stream pauses until the reader pulls.
155
+ // A reader that cancels (it stopped early) closes the body; data, 'end' or
156
+ // 'error' still in flight must then do nothing. Calling close() on it threw
157
+ // from an event handler and killed the process (prod, 2026-10-14).
158
+ let open = true;
159
+ const finish = (settle: () => void) => {
160
+ if (!open) return;
161
+ open = false;
162
+ settle();
163
+ };
155
164
  const bodyStream = empty ? null : new ReadableStream<Uint8Array>({
156
165
  start(controller) {
157
166
  req.on('data', (chunk: Uint8Array) => {
167
+ if (!open) return;
158
168
  controller.enqueue(new Uint8Array(chunk));
159
169
  if ((controller.desiredSize ?? 1) <= 0) req.pause();
160
170
  });
161
- req.once('end', () => controller.close());
162
- req.once('error', (e: unknown) => controller.error(e));
171
+ req.once('end', () => finish(() => controller.close()));
172
+ req.once('error', (e: unknown) => finish(() => controller.error(e)));
163
173
  req.once('close', () => {
164
- if (!req.readableEnded) { try { controller.error(new Error(`HTTP/2 stream closed before its end (code ${req.rstCode})`)); } catch {} }
174
+ if (!req.readableEnded) finish(() => controller.error(new Error(`HTTP/2 stream closed before its end (code ${req.rstCode})`)));
165
175
  });
166
176
  },
167
177
  pull() { if (req.isPaused()) req.resume(); },
168
- cancel() { req.close(); },
178
+ cancel() { open = false; req.close(); },
169
179
  }, { highWaterMark: 4 * 1024 * 1024, size: (chunk) => chunk?.byteLength ?? 0 });
170
180
  const response = new Response(bodyStream, { status, headers: out });
171
181
  // Response.url is read-only; the generated client never reads it, but keep it right.