@ai-ecoverse/slicc-kernel 1.154.2 → 1.155.0

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.
@@ -78,7 +78,8 @@ function bodyStream(id, state, post) {
78
78
  const next = state.body.shift();
79
79
  if (next) controller.enqueue(next);
80
80
  else controller.close();
81
- }
81
+ },
82
+ cancel: () => post({ id, bodyCancel: true })
82
83
  },
83
84
  { highWaterMark: 0 }
84
85
  );
@@ -99,14 +100,16 @@ function embedderAnswerer(port, hookFor) {
99
100
  throw Object.assign(new Error(`this page does not answer ${ask.kind}`), {
100
101
  name: "NotSupportedError"
101
102
  });
103
+ const body = bodyStream(ask.id, state, post);
102
104
  const reply = await hook.handle({
103
105
  kind: ask.kind,
104
106
  options: ask.options,
105
- body: bodyStream(ask.id, state, post),
107
+ body,
106
108
  stamp: ask.stamp,
107
109
  signal: state.abort.signal,
108
110
  progress: (line) => post({ id: ask.id, progress: String(line) })
109
111
  });
112
+ if (!(reply instanceof ReadableStream)) post({ id: ask.id, bodyCancel: true });
110
113
  state.reader = bytesOf(reply).getReader();
111
114
  post({ id: ask.id, ready: true });
112
115
  } catch (err) {