milkio 0.2.17 → 0.3.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.
@@ -179,7 +179,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
179
179
  stream = new ReadableStream({
180
180
  async pull(controller) {
181
181
  control = controller;
182
- controller.enqueue(`data:$MILKIO_FAIL@${JSON.stringify(TSON.encode(resultsRaw.$result))}\n\n`);
182
+ controller.enqueue(`data:@${JSON.stringify(TSON.encode(resultsRaw.$result))}\n\n`);
183
183
  controller.close();
184
184
  },
185
185
  cancel() {
@@ -198,7 +198,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
198
198
  async pull(controller: ReadableStreamDirectController) {
199
199
  control = controller;
200
200
  try {
201
- controller.write(`data:$MILKIO_SUCC@${JSON.stringify(TSON.encode(resultsRaw.$result))}\n\n`);
201
+ controller.write(`data:@${JSON.stringify(TSON.encode(resultsRaw.$result))}\n\n`);
202
202
  for await (const value of generator) {
203
203
  if (!request.request.signal.aborted) {
204
204
  const result: string = JSON.stringify(TSON.encode(value));
@@ -210,9 +210,9 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
210
210
  }
211
211
  } catch (error) {
212
212
  const result = handleCatchError(error, executeId);
213
- controller.write(`data:$MILKIO_FAIL@${JSON.stringify(TSON.encode(result))}\n\n`);
214
- await new Promise((resolve) => setTimeout(resolve, 1));
213
+ controller.write(`data:@${JSON.stringify(TSON.encode(result))}\n\n`);
215
214
  }
215
+ await new Promise((resolve) => setTimeout(resolve, 0));
216
216
  controller.close();
217
217
  },
218
218
  cancel() {
@@ -225,7 +225,7 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
225
225
  async pull(controller) {
226
226
  control = controller;
227
227
  try {
228
- controller.enqueue(`data:$MILKIO_SUCC@${JSON.stringify(TSON.encode(resultsRaw.$result))}\n\n`);
228
+ controller.enqueue(`data:@${JSON.stringify(TSON.encode(resultsRaw.$result))}\n\n`);
229
229
  for await (const value of generator) {
230
230
  if (!request.request.signal.aborted) {
231
231
  const result: string = JSON.stringify(TSON.encode(value));
@@ -237,9 +237,9 @@ export function defineHttpHandler(app: MilkioApp, options: ExecuteHttpServerOpti
237
237
  }
238
238
  } catch (error) {
239
239
  const result = handleCatchError(error, executeId);
240
- controller.enqueue(`data:$MILKIO_FAIL@${JSON.stringify(TSON.encode(result))}\n\n`);
241
- await new Promise((resolve) => setTimeout(resolve, 1));
240
+ controller.enqueue(`data:@${JSON.stringify(TSON.encode(result))}\n\n`);
242
241
  }
242
+ await new Promise((resolve) => setTimeout(resolve, 0));
243
243
  controller.close();
244
244
  },
245
245
  cancel() {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "milkio",
3
3
  "type": "module",
4
4
  "module": "index.ts",
5
- "version": "0.2.17",
5
+ "version": "0.3.0",
6
6
  "peerDependencies": {
7
7
  "typescript": "^5.4.2"
8
8
  },