@workflow/world-testing 5.0.0-beta.31 → 5.0.0-beta.32

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.
@@ -24374,7 +24374,7 @@ var version2;
24374
24374
  var init_version = __esm({
24375
24375
  "../core/dist/version.js"() {
24376
24376
  "use strict";
24377
- version2 = "5.0.0-beta.31";
24377
+ version2 = "5.0.0-beta.32";
24378
24378
  }
24379
24379
  });
24380
24380
 
@@ -26220,6 +26220,21 @@ function createReconnectingFramedStream(runId, name, startIndex) {
26220
26220
  }, "cancel")
26221
26221
  });
26222
26222
  }
26223
+ function recordStreamWriteFlush(startEpochMs, dispatchEpochMs, runId, name, chunkCount, byteCount) {
26224
+ void (async () => {
26225
+ await recordElapsedSpan("workflow.stream.flush", startEpochMs, {
26226
+ kind: await getSpanKind("CLIENT"),
26227
+ attributes: {
26228
+ "workflow.run.id": runId,
26229
+ "workflow.stream.name": name,
26230
+ "workflow.stream.operation": "flush",
26231
+ "workflow.stream.flush.buffer_dwell_ms": dispatchEpochMs - startEpochMs,
26232
+ "workflow.stream.flush.chunks": chunkCount,
26233
+ "workflow.stream.flush.bytes": byteCount
26234
+ }
26235
+ });
26236
+ })();
26237
+ }
26223
26238
  function getAllBaseReducers(global2 = globalThis) {
26224
26239
  return {
26225
26240
  ...getClassReducers(),
@@ -27147,6 +27162,7 @@ var init_serialization2 = __esm({
27147
27162
  getStreamFlushIntervalMs = /* @__PURE__ */ __name(() => envNumber("WORKFLOW_STREAM_FLUSH_INTERVAL_MS", STREAM_FLUSH_INTERVAL_MS, {
27148
27163
  integer: true
27149
27164
  }), "getStreamFlushIntervalMs");
27165
+ __name(recordStreamWriteFlush, "recordStreamWriteFlush");
27150
27166
  WorkflowServerWritableStream = class extends WritableStream {
27151
27167
  static {
27152
27168
  __name(this, "WorkflowServerWritableStream");
@@ -27182,6 +27198,7 @@ var init_serialization2 = __esm({
27182
27198
  let flushTimer = null;
27183
27199
  let flushPromise = null;
27184
27200
  let resolvedFlushIntervalMs;
27201
+ let batchStartAt;
27185
27202
  const flush = /* @__PURE__ */ __name(async () => {
27186
27203
  if (flushTimer) {
27187
27204
  clearTimeout(flushTimer);
@@ -27190,16 +27207,29 @@ var init_serialization2 = __esm({
27190
27207
  if (buffer2.length === 0) return;
27191
27208
  await ensureRunReady();
27192
27209
  const chunksToFlush = buffer2.slice();
27210
+ const batchStart = batchStartAt;
27211
+ batchStartAt = void 0;
27212
+ const dispatchAt = Date.now();
27193
27213
  const world = await worldPromise;
27194
27214
  if (resolvedFlushIntervalMs === void 0) {
27195
27215
  resolvedFlushIntervalMs = world.streamFlushIntervalMs ?? getStreamFlushIntervalMs();
27196
27216
  }
27197
- if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
27198
- await world.streams.writeMulti(runId, name, chunksToFlush);
27199
- } else {
27200
- for (const chunk of chunksToFlush) {
27201
- await world.streams.write(runId, name, chunk);
27217
+ try {
27218
+ if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
27219
+ await world.streams.writeMulti(runId, name, chunksToFlush);
27220
+ } else {
27221
+ for (const chunk of chunksToFlush) {
27222
+ await world.streams.write(runId, name, chunk);
27223
+ }
27224
+ }
27225
+ } catch (error48) {
27226
+ if (batchStart !== void 0) {
27227
+ batchStartAt = batchStartAt === void 0 ? batchStart : Math.min(batchStartAt, batchStart);
27202
27228
  }
27229
+ throw error48;
27230
+ }
27231
+ if (batchStart !== void 0) {
27232
+ recordStreamWriteFlush(batchStart, dispatchAt, runId, name, chunksToFlush.length, chunksToFlush.reduce((sum, c) => sum + c.byteLength, 0));
27203
27233
  }
27204
27234
  buffer2 = [];
27205
27235
  }, "flush");
@@ -27219,6 +27249,7 @@ var init_serialization2 = __esm({
27219
27249
  }, "scheduleFlush");
27220
27250
  super({
27221
27251
  async write(chunk) {
27252
+ if (batchStartAt === void 0) batchStartAt = Date.now();
27222
27253
  if (flushPromise) {
27223
27254
  await flushPromise;
27224
27255
  flushPromise = null;
@@ -27679,7 +27710,7 @@ __name(start, "start");
27679
27710
  value: "start",
27680
27711
  configurable: true
27681
27712
  });
27682
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.31//start");
27713
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.32//start");
27683
27714
 
27684
27715
  // ../core/dist/runtime/runs.js
27685
27716
  async function wakeUpRun(world, runId, options) {
@@ -28015,7 +28046,7 @@ var Run = class _Run {
28015
28046
  value: "wakeUp",
28016
28047
  configurable: true
28017
28048
  });
28018
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#wakeUp");
28049
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#wakeUp");
28019
28050
  (function(__wf_fn, __wf_id) {
28020
28051
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28021
28052
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28024,7 +28055,7 @@ var Run = class _Run {
28024
28055
  value: "cancel",
28025
28056
  configurable: true
28026
28057
  });
28027
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#cancel");
28058
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#cancel");
28028
28059
  (function(__wf_fn, __wf_id) {
28029
28060
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28030
28061
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28033,7 +28064,7 @@ var Run = class _Run {
28033
28064
  value: "getReadable",
28034
28065
  configurable: true
28035
28066
  });
28036
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#getReadable");
28067
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#getReadable");
28037
28068
  (function(__wf_fn, __wf_id) {
28038
28069
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28039
28070
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28042,7 +28073,7 @@ var Run = class _Run {
28042
28073
  value: "exists",
28043
28074
  configurable: true
28044
28075
  });
28045
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#exists");
28076
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#exists");
28046
28077
  (function(__wf_fn, __wf_id) {
28047
28078
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28048
28079
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28051,7 +28082,7 @@ var Run = class _Run {
28051
28082
  value: "status",
28052
28083
  configurable: true
28053
28084
  });
28054
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#status");
28085
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#status");
28055
28086
  (function(__wf_fn, __wf_id) {
28056
28087
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28057
28088
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28060,7 +28091,7 @@ var Run = class _Run {
28060
28091
  value: "returnValue",
28061
28092
  configurable: true
28062
28093
  });
28063
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#returnValue");
28094
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#returnValue");
28064
28095
  (function(__wf_fn, __wf_id) {
28065
28096
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28066
28097
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28069,7 +28100,7 @@ var Run = class _Run {
28069
28100
  value: "workflowName",
28070
28101
  configurable: true
28071
28102
  });
28072
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#workflowName");
28103
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#workflowName");
28073
28104
  (function(__wf_fn, __wf_id) {
28074
28105
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28075
28106
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28078,7 +28109,7 @@ var Run = class _Run {
28078
28109
  value: "createdAt",
28079
28110
  configurable: true
28080
28111
  });
28081
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#createdAt");
28112
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#createdAt");
28082
28113
  (function(__wf_fn, __wf_id) {
28083
28114
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28084
28115
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28087,7 +28118,7 @@ var Run = class _Run {
28087
28118
  value: "startedAt",
28088
28119
  configurable: true
28089
28120
  });
28090
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#startedAt");
28121
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#startedAt");
28091
28122
  (function(__wf_fn, __wf_id) {
28092
28123
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28093
28124
  __wf_reg.set(__wf_id, __wf_fn);
@@ -28096,7 +28127,7 @@ var Run = class _Run {
28096
28127
  value: "completedAt",
28097
28128
  configurable: true
28098
28129
  });
28099
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.31//Run#completedAt");
28130
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.32//Run#completedAt");
28100
28131
  (function(__wf_cls, __wf_id) {
28101
28132
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
28102
28133
  __wf_reg.set(__wf_id, __wf_cls);
@@ -28106,7 +28137,7 @@ var Run = class _Run {
28106
28137
  enumerable: false,
28107
28138
  configurable: false
28108
28139
  });
28109
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.31//Run");
28140
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.32//Run");
28110
28141
 
28111
28142
  // ../workflow/dist/stdlib.js
28112
28143
  async function fetch2(...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workflow/world-testing",
3
- "version": "5.0.0-beta.31",
3
+ "version": "5.0.0-beta.32",
4
4
  "description": "Testing utilities and World implementation for Workflow SDK",
5
5
  "main": "dist/src/index.mjs",
6
6
  "files": [
@@ -21,12 +21,12 @@
21
21
  "hono": "4.12.25",
22
22
  "jsonlines": "0.1.1",
23
23
  "zod": "~4.3.6",
24
- "@workflow/cli": "5.0.0-beta.31",
25
- "@workflow/core": "5.0.0-beta.31",
24
+ "@workflow/cli": "5.0.0-beta.32",
25
+ "@workflow/core": "5.0.0-beta.32",
26
26
  "@workflow/utils": "5.0.0-beta.6",
27
27
  "@workflow/world": "5.0.0-beta.19",
28
28
  "@workflow/world-local": "5.0.0-beta.27",
29
- "workflow": "5.0.0-beta.31"
29
+ "workflow": "5.0.0-beta.32"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/jsonlines": "0.1.5",