copilot-api-plus 1.0.33 → 1.0.34

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/main.js CHANGED
@@ -2319,12 +2319,14 @@ function transformStreamResponse(response, model) {
2319
2319
  */
2320
2320
  async function processStream(reader, decoder, state$1, controller) {
2321
2321
  const emit = (event) => emitSSEEvent(event, controller, state$1);
2322
- while (true) {
2322
+ let finished = false;
2323
+ while (!finished) {
2323
2324
  const { done, value } = await reader.read();
2324
2325
  if (done) break;
2325
2326
  const chunk = decoder.decode(value, { stream: true });
2326
2327
  const lines = processChunk(chunk, state$1);
2327
2328
  for (const line of lines) {
2329
+ if (finished) break;
2328
2330
  const data = parseSSELine(line);
2329
2331
  if (!data) continue;
2330
2332
  const { candidates, usage } = extractFromData(data);
@@ -2335,7 +2337,11 @@ async function processStream(reader, decoder, state$1, controller) {
2335
2337
  const candidate = candidates[0];
2336
2338
  const parts = candidate?.content?.parts ?? [];
2337
2339
  for (const part of parts) processPart(part, state$1, emit);
2338
- if (candidate?.finishReason === "STOP") handleFinish(state$1, emit);
2340
+ if (candidate?.finishReason === "STOP") {
2341
+ handleFinish(state$1, emit);
2342
+ finished = true;
2343
+ break;
2344
+ }
2339
2345
  }
2340
2346
  }
2341
2347
  }