@workflow/world-testing 5.0.0-beta.41 → 5.0.0-beta.42

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.
@@ -406,7 +406,7 @@ function buildFramedDetails(hint2, slug) {
406
406
  });
407
407
  return out;
408
408
  }
409
- var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
409
+ var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, StreamExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
410
410
  var init_dist2 = __esm({
411
411
  "../errors/dist/index.js"() {
412
412
  "use strict";
@@ -682,6 +682,27 @@ Caused by: ${options.cause.stack}`;
682
682
  return isError(value) && value.name === "RunExpiredError";
683
683
  }
684
684
  };
685
+ StreamExpiredError = class extends WorkflowWorldError {
686
+ static {
687
+ __name(this, "StreamExpiredError");
688
+ }
689
+ runId;
690
+ streamId;
691
+ expiredAt;
692
+ constructor(message, runId, streamId, expiredAt) {
693
+ super(message, {
694
+ status: 410,
695
+ code: "stream-expired"
696
+ });
697
+ this.runId = runId;
698
+ this.streamId = streamId;
699
+ this.expiredAt = expiredAt;
700
+ this.name = "StreamExpiredError";
701
+ }
702
+ static is(value) {
703
+ return isError(value) && value.name === "StreamExpiredError";
704
+ }
705
+ };
685
706
  ThrottleError = class extends WorkflowWorldError {
686
707
  static {
687
708
  __name(this, "ThrottleError");
@@ -17399,7 +17420,7 @@ function getQueueTopicPrefix(kind, namespace) {
17399
17420
  }
17400
17421
  return "__wkf_workflow_";
17401
17422
  }
17402
- var QueuePrefix, ValidQueueName, QueueNamespace, MessageId, TraceCarrierSchema, RunInputSchema, HookResumeInputSchema, WorkflowInvokePayloadSchema, HealthCheckPayloadSchema, QueuePayloadSchema;
17423
+ var QueuePrefix, ValidQueueName, QueueNamespace, MessageId, TraceCarrierSchema, RunInputSchema, StepDispatchInputSchema, HookResumeInputSchema, HookResumeTimingSchema, WorkflowInvokePayloadSchema, HealthCheckPayloadSchema, QueuePayloadSchema;
17403
17424
  var init_queue = __esm({
17404
17425
  "../world/dist/queue.js"() {
17405
17426
  "use strict";
@@ -17446,6 +17467,19 @@ var init_queue = __esm({
17446
17467
  */
17447
17468
  environment: external_exports.string().optional()
17448
17469
  });
17470
+ StepDispatchInputSchema = external_exports.object({
17471
+ /**
17472
+ * The serialized step input, reused verbatim from the direct write. Always
17473
+ * binary: producers only attach `stepInput` when the dehydrated input is a
17474
+ * `Uint8Array` and the run's queue transport preserves bytes (CBOR).
17475
+ * Validated here so a malformed or transport-mangled payload fails the
17476
+ * message parse instead of being silently written into a `step_created` as
17477
+ * non-binary data. `Buffer` is a `Uint8Array` subclass and passes.
17478
+ */
17479
+ input: external_exports.custom((value) => value instanceof Uint8Array, {
17480
+ message: "stepInput.input must be a Uint8Array"
17481
+ })
17482
+ });
17449
17483
  HookResumeInputSchema = external_exports.object({
17450
17484
  /** Stable idempotency key minted once per `resumeHook()` call. */
17451
17485
  resumeId: external_exports.string(),
@@ -17479,6 +17513,22 @@ var init_queue = __esm({
17479
17513
  */
17480
17514
  deploymentId: external_exports.string().optional()
17481
17515
  });
17516
+ HookResumeTimingSchema = external_exports.object({
17517
+ /** Epoch ms at entry into `resumeHook()` — the start of the TTR window. */
17518
+ resumeRequestedAtMs: external_exports.number(),
17519
+ /** Epoch ms immediately before the queue publish was requested. */
17520
+ queuePublishRequestedAtMs: external_exports.number(),
17521
+ /** Which `resumeHook()` dispatch path ran: `parallel` or `sequential`. */
17522
+ strategy: external_exports.string().optional(),
17523
+ /** Epoch ms the final consumer's queue handler was entered. */
17524
+ consumerStartedAtMs: external_exports.number().optional(),
17525
+ /** Epoch ms this invocation's first replay pass began. */
17526
+ replayStartedAtMs: external_exports.number().optional(),
17527
+ /** Epoch ms replay first encountered a durable step after the resume. */
17528
+ nextStepEncounteredAtMs: external_exports.number().optional(),
17529
+ /** How the consumer initialized replay state: see `ResumeSetupSource`. */
17530
+ setupSource: external_exports.string().optional()
17531
+ });
17482
17532
  WorkflowInvokePayloadSchema = external_exports.object({
17483
17533
  runId: external_exports.string(),
17484
17534
  traceCarrier: TraceCarrierSchema.optional(),
@@ -17512,7 +17562,28 @@ var init_queue = __esm({
17512
17562
  * fast path. A consumer that understands this field idempotently ensures the
17513
17563
  * `hook_received` event exists (keyed by `resumeId`) before replaying.
17514
17564
  */
17515
- hookInput: HookResumeInputSchema.optional()
17565
+ hookInput: HookResumeInputSchema.optional(),
17566
+ /**
17567
+ * Resilient step dispatch data, only present alongside `stepId` when the
17568
+ * producer parallelized the `step_created` write with this queue publish. A
17569
+ * consumer that understands this field idempotently ensures the
17570
+ * `step_created` event exists (keyed by `stepId`) before executing the step.
17571
+ */
17572
+ stepInput: StepDispatchInputSchema.optional(),
17573
+ /**
17574
+ * Hook-resume TTR timing. Present on both `resumeHook()` dispatch paths
17575
+ * (unlike `hookInput`, which only rides the parallel fast path), and
17576
+ * forwarded onto a dispatched step message when the resuming invocation
17577
+ * hands the next durable step to another invocation. Purely observational —
17578
+ * see {@link HookResumeTimingSchema}.
17579
+ *
17580
+ * `.catch(undefined)` because this field must never be able to fail the
17581
+ * parse of the invocation payload: a malformed value (a NaN boundary, a
17582
+ * shape change from a future producer) would otherwise throw on every
17583
+ * delivery of that message and burn the run's delivery budget over a
17584
+ * telemetry field. Anything unparseable degrades to "no measurement".
17585
+ */
17586
+ hookResumeTiming: HookResumeTimingSchema.optional().catch(void 0)
17516
17587
  });
17517
17588
  HealthCheckPayloadSchema = external_exports.object({
17518
17589
  __healthCheck: external_exports.literal(true),
@@ -17669,7 +17740,7 @@ var init_spec_version = __esm({
17669
17740
  SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
17670
17741
  SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
17671
17742
  SPEC_VERSION_SUPPORTS_SLOT_IDENTITY = 6;
17672
- SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_COMPRESSION;
17743
+ SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
17673
17744
  SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
17674
17745
  __name(isLegacySpecVersion, "isLegacySpecVersion");
17675
17746
  }
@@ -20508,7 +20579,7 @@ function getReviversForMode(mode, global2 = globalThis, extraRevivers) {
20508
20579
  }
20509
20580
  return base;
20510
20581
  }
20511
- var encoder, decoder, devalueCodec;
20582
+ var encoder, decoder, MAX_SPARSE_ARRAY_LENGTH, parseOptions, devalueCodec;
20512
20583
  var init_codec_devalue = __esm({
20513
20584
  "../core/dist/serialization/codec-devalue.js"() {
20514
20585
  "use strict";
@@ -20520,6 +20591,17 @@ var init_codec_devalue = __esm({
20520
20591
  init_types();
20521
20592
  encoder = new TextEncoder();
20522
20593
  decoder = new TextDecoder();
20594
+ MAX_SPARSE_ARRAY_LENGTH = 1e5;
20595
+ parseOptions = {
20596
+ operations: {
20597
+ createSparseArray(length) {
20598
+ if (length > MAX_SPARSE_ARRAY_LENGTH) {
20599
+ throw new RangeError(`Sparse array length ${length} exceeds the maximum of ${MAX_SPARSE_ARRAY_LENGTH}`);
20600
+ }
20601
+ return default_parse_operations.createSparseArray(length);
20602
+ }
20603
+ }
20604
+ };
20523
20605
  __name(getReducersForMode, "getReducersForMode");
20524
20606
  __name(getReviversForMode, "getReviversForMode");
20525
20607
  devalueCodec = {
@@ -20534,11 +20616,11 @@ var init_codec_devalue = __esm({
20534
20616
  deserialize(data, mode, options) {
20535
20617
  const revivers = getReviversForMode(mode, options?.global, options?.extraRevivers);
20536
20618
  const str = decoder.decode(data);
20537
- return parse3(str, revivers);
20619
+ return parse3(str, revivers, parseOptions);
20538
20620
  },
20539
20621
  deserializeLegacy(data, mode, options) {
20540
20622
  const revivers = getReviversForMode(mode, options?.global, options?.extraRevivers);
20541
- return unflatten(data, revivers);
20623
+ return unflatten(data, revivers, parseOptions);
20542
20624
  }
20543
20625
  };
20544
20626
  }
@@ -21059,7 +21141,7 @@ function SemanticConvention(...names) {
21059
21141
  value
21060
21142
  ]));
21061
21143
  }
21062
- var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, HookResumeSetupSource, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
21144
+ var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, HookResumeSetupSource, StepResilientDispatchRecovered, StepResilientDispatchMaterialized, ResumeTotalMs, ResumeProducerPrepMs, ResumeQueueDeliveryMs, ResumeSetupMs, ResumeReplayMs, ResumeStepDispatchMs, ResumeStepClaimMs, ResumeStepPrepareMs, ResumeTrigger, ResumeStrategy, ResumeSetupSource, ResumeStepExecution, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
21063
21145
  var init_semantic_conventions = __esm({
21064
21146
  "../core/dist/telemetry/semantic-conventions.js"() {
21065
21147
  "use strict";
@@ -21136,6 +21218,20 @@ var init_semantic_conventions = __esm({
21136
21218
  HookResilientResume = SemanticConvention("workflow.hook.resilient_resume");
21137
21219
  HookResilientResumeMaterialized = SemanticConvention("workflow.hook.resilient_resume_materialized");
21138
21220
  HookResumeSetupSource = SemanticConvention("workflow.resume_setup_source");
21221
+ StepResilientDispatchRecovered = SemanticConvention("workflow.step.resilient_dispatch_recovered");
21222
+ StepResilientDispatchMaterialized = SemanticConvention("workflow.step.resilient_dispatch_materialized");
21223
+ ResumeTotalMs = SemanticConvention("workflow.resume.total_ms");
21224
+ ResumeProducerPrepMs = SemanticConvention("workflow.resume.phase.producer_prep_ms");
21225
+ ResumeQueueDeliveryMs = SemanticConvention("workflow.resume.phase.queue_delivery_ms");
21226
+ ResumeSetupMs = SemanticConvention("workflow.resume.phase.resume_setup_ms");
21227
+ ResumeReplayMs = SemanticConvention("workflow.resume.phase.replay_ms");
21228
+ ResumeStepDispatchMs = SemanticConvention("workflow.resume.phase.step_dispatch_ms");
21229
+ ResumeStepClaimMs = SemanticConvention("workflow.resume.phase.step_claim_ms");
21230
+ ResumeStepPrepareMs = SemanticConvention("workflow.resume.phase.step_prepare_ms");
21231
+ ResumeTrigger = SemanticConvention("workflow.resume.trigger");
21232
+ ResumeStrategy = SemanticConvention("workflow.resume.strategy");
21233
+ ResumeSetupSource = SemanticConvention("workflow.resume.setup_source");
21234
+ ResumeStepExecution = SemanticConvention("workflow.resume.step_execution");
21139
21235
  WebhookHandlersTriggered = SemanticConvention("webhook.handlers.triggered");
21140
21236
  WorkflowSuspensionState = SemanticConvention("workflow.suspension.state");
21141
21237
  WorkflowSuspensionHookCount = SemanticConvention("workflow.suspension.hook_count");
@@ -23862,7 +23958,7 @@ var require_parse_options = __commonJS({
23862
23958
  loose: true
23863
23959
  });
23864
23960
  var emptyOpts = Object.freeze({});
23865
- var parseOptions = /* @__PURE__ */ __name((options) => {
23961
+ var parseOptions2 = /* @__PURE__ */ __name((options) => {
23866
23962
  if (!options) {
23867
23963
  return emptyOpts;
23868
23964
  }
@@ -23871,7 +23967,7 @@ var require_parse_options = __commonJS({
23871
23967
  }
23872
23968
  return options;
23873
23969
  }, "parseOptions");
23874
- module.exports = parseOptions;
23970
+ module.exports = parseOptions2;
23875
23971
  }
23876
23972
  });
23877
23973
 
@@ -23907,14 +24003,14 @@ var require_semver2 = __commonJS({
23907
24003
  var debug = require_debug();
23908
24004
  var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
23909
24005
  var { safeRe: re, t } = require_re();
23910
- var parseOptions = require_parse_options();
24006
+ var parseOptions2 = require_parse_options();
23911
24007
  var { compareIdentifiers } = require_identifiers();
23912
24008
  var SemVer = class _SemVer {
23913
24009
  static {
23914
24010
  __name(this, "SemVer");
23915
24011
  }
23916
24012
  constructor(version3, options) {
23917
- options = parseOptions(options);
24013
+ options = parseOptions2(options);
23918
24014
  if (version3 instanceof _SemVer) {
23919
24015
  if (version3.loose === !!options.loose && version3.includePrerelease === !!options.includePrerelease) {
23920
24016
  return version3;
@@ -24614,7 +24710,7 @@ var require_range = __commonJS({
24614
24710
  __name(this, "Range");
24615
24711
  }
24616
24712
  constructor(range, options) {
24617
- options = parseOptions(options);
24713
+ options = parseOptions2(options);
24618
24714
  if (range instanceof _Range) {
24619
24715
  if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
24620
24716
  return range;
@@ -24765,7 +24861,7 @@ var require_range = __commonJS({
24765
24861
  module.exports = Range;
24766
24862
  var LRU = require_lrucache();
24767
24863
  var cache = new LRU();
24768
- var parseOptions = require_parse_options();
24864
+ var parseOptions2 = require_parse_options();
24769
24865
  var Comparator = require_comparator();
24770
24866
  var debug = require_debug();
24771
24867
  var SemVer = require_semver2();
@@ -25003,7 +25099,7 @@ var require_comparator = __commonJS({
25003
25099
  return ANY;
25004
25100
  }
25005
25101
  constructor(comp, options) {
25006
- options = parseOptions(options);
25102
+ options = parseOptions2(options);
25007
25103
  if (comp instanceof _Comparator) {
25008
25104
  if (comp.loose === !!options.loose) {
25009
25105
  return comp;
@@ -25071,7 +25167,7 @@ var require_comparator = __commonJS({
25071
25167
  }
25072
25168
  return new Range(this.value, options).test(comp.semver);
25073
25169
  }
25074
- options = parseOptions(options);
25170
+ options = parseOptions2(options);
25075
25171
  if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
25076
25172
  return false;
25077
25173
  }
@@ -25097,7 +25193,7 @@ var require_comparator = __commonJS({
25097
25193
  }
25098
25194
  };
25099
25195
  module.exports = Comparator;
25100
- var parseOptions = require_parse_options();
25196
+ var parseOptions2 = require_parse_options();
25101
25197
  var { safeRe: re, t } = require_re();
25102
25198
  var cmp = require_cmp();
25103
25199
  var debug = require_debug();
@@ -25810,7 +25906,7 @@ var version2;
25810
25906
  var init_version = __esm({
25811
25907
  "../core/dist/version.js"() {
25812
25908
  "use strict";
25813
- version2 = "5.0.0-beta.41";
25909
+ version2 = "5.0.0-beta.42";
25814
25910
  }
25815
25911
  });
25816
25912
 
@@ -31009,9 +31105,9 @@ async function getHookByToken(token) {
31009
31105
  return hook;
31010
31106
  }
31011
31107
  async function resumeHook(tokenOrHook, payload, encryptionKeyOverride) {
31012
- return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false);
31108
+ return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false, Date.now());
31013
31109
  }
31014
- async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp) {
31110
+ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs) {
31015
31111
  return await waitedUntil(() => {
31016
31112
  return trace("hook.resume", async (span) => {
31017
31113
  const world = await getWorldLazy();
@@ -31103,9 +31199,15 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31103
31199
  }
31104
31200
  throw err;
31105
31201
  }
31202
+ const queuePublishRequestedAtMs = Date.now();
31106
31203
  await world.queue(queueName, {
31107
31204
  runId: hook.runId,
31108
- traceCarrier: resumeContext.traceCarrier ?? void 0
31205
+ traceCarrier: resumeContext.traceCarrier ?? void 0,
31206
+ hookResumeTiming: {
31207
+ resumeRequestedAtMs,
31208
+ queuePublishRequestedAtMs,
31209
+ strategy: "sequential"
31210
+ }
31109
31211
  }, queueOptions);
31110
31212
  return hook;
31111
31213
  }
@@ -31114,18 +31216,9 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31114
31216
  span?.setAttributes({
31115
31217
  "workflow.hook.resume_id": resumeId
31116
31218
  });
31117
- const [eventResult, queueResult] = await Promise.allSettled([
31118
- world.events.create(hook.runId, {
31119
- eventType: "hook_received",
31120
- specVersion: SPEC_VERSION_CURRENT,
31121
- correlationId: hook.hookId,
31122
- eventData
31123
- }, {
31124
- v1Compat,
31125
- resumeId,
31126
- resumePayloadDigest: payloadDigest
31127
- }),
31128
- world.queue(queueName, {
31219
+ const publishInvocation = /* @__PURE__ */ __name(() => {
31220
+ const queuePublishRequestedAtMs = Date.now();
31221
+ return world.queue(queueName, {
31129
31222
  runId: hook.runId,
31130
31223
  traceCarrier: resumeContext.traceCarrier ?? void 0,
31131
31224
  hookInput: {
@@ -31138,8 +31231,26 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31138
31231
  // check: lets a misrouted delivery re-route before its
31139
31232
  // hoisted hook_received write instead of after.
31140
31233
  deploymentId: resumeContext.deploymentId
31234
+ },
31235
+ hookResumeTiming: {
31236
+ resumeRequestedAtMs,
31237
+ queuePublishRequestedAtMs,
31238
+ strategy: "parallel"
31141
31239
  }
31142
- }, queueOptions)
31240
+ }, queueOptions);
31241
+ }, "publishInvocation");
31242
+ const [eventResult, queueResult] = await Promise.allSettled([
31243
+ world.events.create(hook.runId, {
31244
+ eventType: "hook_received",
31245
+ specVersion: SPEC_VERSION_CURRENT,
31246
+ correlationId: hook.hookId,
31247
+ eventData
31248
+ }, {
31249
+ v1Compat,
31250
+ resumeId,
31251
+ resumePayloadDigest: payloadDigest
31252
+ }),
31253
+ publishInvocation()
31143
31254
  ]);
31144
31255
  if (queueResult.status === "rejected") {
31145
31256
  throw queueResult.reason;
@@ -31182,6 +31293,7 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31182
31293
  });
31183
31294
  }
31184
31295
  async function resumeWebhook(token, request) {
31296
+ const resumeRequestedAtMs = Date.now();
31185
31297
  const { hook, encryptionKey } = await getHookByTokenWithKey(token);
31186
31298
  if (hook.isWebhook === false) {
31187
31299
  throw new HookNotFoundError(token);
@@ -31205,7 +31317,7 @@ async function resumeWebhook(token, request) {
31205
31317
  status: 202
31206
31318
  });
31207
31319
  }
31208
- await resumeHookImpl(hook, request, encryptionKey, true);
31320
+ await resumeHookImpl(hook, request, encryptionKey, true, resumeRequestedAtMs);
31209
31321
  if (responseReadable) {
31210
31322
  const reader = responseReadable.getReader();
31211
31323
  const chunk = await reader.read();
@@ -31579,7 +31691,8 @@ function createReconnectingFramedStream(runId, name, startIndex) {
31579
31691
  try {
31580
31692
  await connect();
31581
31693
  return;
31582
- } catch {
31694
+ } catch (error48) {
31695
+ if (StreamExpiredError.is(error48)) throw error48;
31583
31696
  }
31584
31697
  }
31585
31698
  }
@@ -33379,7 +33492,7 @@ __name(start, "start");
33379
33492
  value: "start",
33380
33493
  configurable: true
33381
33494
  });
33382
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.41//start");
33495
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.42//start");
33383
33496
 
33384
33497
  // ../core/dist/runtime/runs.js
33385
33498
  async function wakeUpRun(world, runId, options) {
@@ -33723,7 +33836,7 @@ var Run = class _Run {
33723
33836
  value: "wakeUp",
33724
33837
  configurable: true
33725
33838
  });
33726
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#wakeUp");
33839
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#wakeUp");
33727
33840
  (function(__wf_fn, __wf_id) {
33728
33841
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33729
33842
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33732,7 +33845,7 @@ var Run = class _Run {
33732
33845
  value: "cancel",
33733
33846
  configurable: true
33734
33847
  });
33735
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#cancel");
33848
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#cancel");
33736
33849
  (function(__wf_fn, __wf_id) {
33737
33850
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33738
33851
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33741,7 +33854,7 @@ var Run = class _Run {
33741
33854
  value: "getReadable",
33742
33855
  configurable: true
33743
33856
  });
33744
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#getReadable");
33857
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#getReadable");
33745
33858
  (function(__wf_fn, __wf_id) {
33746
33859
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33747
33860
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33750,7 +33863,7 @@ var Run = class _Run {
33750
33863
  value: "exists",
33751
33864
  configurable: true
33752
33865
  });
33753
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#exists");
33866
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#exists");
33754
33867
  (function(__wf_fn, __wf_id) {
33755
33868
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33756
33869
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33759,7 +33872,7 @@ var Run = class _Run {
33759
33872
  value: "status",
33760
33873
  configurable: true
33761
33874
  });
33762
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#status");
33875
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#status");
33763
33876
  (function(__wf_fn, __wf_id) {
33764
33877
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33765
33878
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33768,7 +33881,7 @@ var Run = class _Run {
33768
33881
  value: "returnValue",
33769
33882
  configurable: true
33770
33883
  });
33771
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#returnValue");
33884
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#returnValue");
33772
33885
  (function(__wf_fn, __wf_id) {
33773
33886
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33774
33887
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33777,7 +33890,7 @@ var Run = class _Run {
33777
33890
  value: "workflowName",
33778
33891
  configurable: true
33779
33892
  });
33780
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#workflowName");
33893
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#workflowName");
33781
33894
  (function(__wf_fn, __wf_id) {
33782
33895
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33783
33896
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33786,7 +33899,7 @@ var Run = class _Run {
33786
33899
  value: "createdAt",
33787
33900
  configurable: true
33788
33901
  });
33789
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#createdAt");
33902
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#createdAt");
33790
33903
  (function(__wf_fn, __wf_id) {
33791
33904
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33792
33905
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33795,7 +33908,7 @@ var Run = class _Run {
33795
33908
  value: "startedAt",
33796
33909
  configurable: true
33797
33910
  });
33798
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#startedAt");
33911
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#startedAt");
33799
33912
  (function(__wf_fn, __wf_id) {
33800
33913
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33801
33914
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33804,7 +33917,7 @@ var Run = class _Run {
33804
33917
  value: "completedAt",
33805
33918
  configurable: true
33806
33919
  });
33807
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.41//Run#completedAt");
33920
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#completedAt");
33808
33921
  (function(__wf_cls, __wf_id) {
33809
33922
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33810
33923
  __wf_reg.set(__wf_id, __wf_cls);
@@ -33814,7 +33927,7 @@ var Run = class _Run {
33814
33927
  enumerable: false,
33815
33928
  configurable: false
33816
33929
  });
33817
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.41//Run");
33930
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.42//Run");
33818
33931
 
33819
33932
  // ../workflow/dist/stdlib.js
33820
33933
  async function fetch2(...args) {