mycomesh-consumer 0.9.11 → 0.9.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/consumer.mjs +5 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mycomesh-consumer",
3
- "version": "0.9.11",
3
+ "version": "0.9.12",
4
4
  "description": "MycoMesh V11 Consumer: a custodied deposit, relay-blind encrypted requests to any Provider, and a local OpenAI-compatible endpoint.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/consumer.mjs CHANGED
@@ -442,6 +442,11 @@ export class Consumer {
442
442
  }
443
443
  if (reply.streamed) {
444
444
  if (!final) throw Object.assign(new Error("stream ended without a result"), { code: "outcome_unknown" });
445
+ // Part of an answer already reached the client and cannot be taken back: never start it again, here
446
+ // or at another Provider, or the client would read half an answer followed by another one.
447
+ if (final.type === "error" && streamed.length) {
448
+ throw Object.assign(new Error(`the answer was cut off: ${final.error}`), { status: 502, dispatched: true });
449
+ }
445
450
  // An error before dispatch (a busy Provider, say) is safe to fail over, exactly as without streaming.
446
451
  reply = final.type === "error"
447
452
  ? { status: final.status || 502, body: { error: final.error, dispatched: final.dispatched } }