@rivetkit/workflow-engine 2.3.0-rc.9 → 2.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.
@@ -1963,7 +1963,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
1963
1963
  * Throws HistoryDivergedError if duplicate detected.
1964
1964
  */
1965
1965
  checkDuplicateName(name) {
1966
- const fullKey = locationToKey(this.storage, this.currentLocation) + "/" + name;
1966
+ const fullKey = `${locationToKey(this.storage, this.currentLocation)}/${name}`;
1967
1967
  if (this.usedNamesInExecution.has(fullKey)) {
1968
1968
  throw new HistoryDivergedError(
1969
1969
  `Duplicate entry name "${name}" at location "${locationToKey(this.storage, this.currentLocation)}". Each step/loop/sleep/queue.next/join/race must have a unique name within its scope.`
@@ -2017,7 +2017,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2017
2017
  validateComplete() {
2018
2018
  const prefix = locationToKey(this.storage, this.currentLocation);
2019
2019
  for (const key of this.storage.history.entries.keys()) {
2020
- const isUnderPrefix = prefix === "" ? true : key.startsWith(prefix + "/") || key === prefix;
2020
+ const isUnderPrefix = prefix === "" ? true : key.startsWith(`${prefix}/`) || key === prefix;
2021
2021
  if (isUnderPrefix) {
2022
2022
  if (!this.visitedKeys.has(key)) {
2023
2023
  throw new HistoryDivergedError(
@@ -2201,7 +2201,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2201
2201
  }
2202
2202
  const maxRetries2 = config2.maxRetries ?? DEFAULT_MAX_RETRIES;
2203
2203
  if (metadata2.attempts > maxRetries2) {
2204
- const lastError = stepData.error ?? metadata2.error;
2204
+ const lastError = metadata2.error;
2205
2205
  const exhaustedError = new StepExhaustedError(
2206
2206
  config2.name,
2207
2207
  lastError
@@ -2290,14 +2290,13 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2290
2290
  });
2291
2291
  return output;
2292
2292
  } catch (error) {
2293
- if (error instanceof StepTimeoutError) {
2294
- if (entry.kind.type === "step") {
2295
- entry.kind.data.error = String(error);
2296
- }
2297
- entry.dirty = true;
2293
+ if (entry.kind.type === "step") {
2294
+ entry.kind.data.error = String(error);
2295
+ }
2296
+ entry.dirty = true;
2297
+ if (error instanceof StepTimeoutError && !config2.retryOnTimeout) {
2298
2298
  metadata.status = "exhausted";
2299
2299
  metadata.error = String(error);
2300
- await this.flushStorage();
2301
2300
  await this.notifyStepError(config2, metadata.attempts, error, {
2302
2301
  willRetry: false
2303
2302
  });
@@ -2311,13 +2310,8 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2311
2310
  );
2312
2311
  }
2313
2312
  if (error instanceof CriticalError || error instanceof RollbackError) {
2314
- if (entry.kind.type === "step") {
2315
- entry.kind.data.error = String(error);
2316
- }
2317
- entry.dirty = true;
2318
2313
  metadata.status = "exhausted";
2319
2314
  metadata.error = String(error);
2320
- await this.flushStorage();
2321
2315
  await this.notifyStepError(config2, metadata.attempts, error, {
2322
2316
  willRetry: false
2323
2317
  });
@@ -2330,14 +2324,9 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2330
2324
  })
2331
2325
  );
2332
2326
  }
2333
- if (entry.kind.type === "step") {
2334
- entry.kind.data.error = String(error);
2335
- }
2336
- entry.dirty = true;
2337
2327
  const willRetry = metadata.attempts <= maxRetries;
2338
2328
  metadata.status = willRetry ? "failed" : "exhausted";
2339
2329
  metadata.error = String(error);
2340
- await this.flushStorage();
2341
2330
  if (willRetry) {
2342
2331
  const retryDelay = calculateBackoff(
2343
2332
  metadata.attempts,
@@ -2361,7 +2350,7 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2361
2350
  attachTryStepFailure(
2362
2351
  new StepExhaustedError(config2.name, String(error)),
2363
2352
  {
2364
- kind: "exhausted",
2353
+ kind: error instanceof StepTimeoutError ? "timeout" : "exhausted",
2365
2354
  stepName: config2.name,
2366
2355
  attempts: metadata.attempts,
2367
2356
  error: extractErrorInfo(error)
@@ -2379,7 +2368,9 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2379
2368
  *
2380
2369
  * Note: This does NOT cancel the underlying operation. JavaScript Promises
2381
2370
  * cannot be cancelled once started. When a timeout occurs:
2382
- * - The step is marked as failed with StepTimeoutError
2371
+ * - The step is rejected with StepTimeoutError. By default this is treated
2372
+ * as a critical failure with no retry. Set retryOnTimeout: true on the
2373
+ * step config to retry timeouts like any other error.
2383
2374
  * - The underlying async operation continues running in the background
2384
2375
  * - Any side effects from the operation may still occur
2385
2376
  *
@@ -4210,4 +4201,4 @@ export {
4210
4201
  runWorkflow,
4211
4202
  replayWorkflowFromStep
4212
4203
  };
4213
- //# sourceMappingURL=chunk-CIDHCIH7.js.map
4204
+ //# sourceMappingURL=chunk-DFNXCZ47.js.map