@rivetkit/workflow-engine 2.3.0-rc.8 → 2.3.0-rc.9

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.
@@ -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 = metadata2.error;
2204
+ const lastError = stepData.error ?? metadata2.error;
2205
2205
  const exhaustedError = new StepExhaustedError(
2206
2206
  config2.name,
2207
2207
  lastError
@@ -2290,13 +2290,14 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2290
2290
  });
2291
2291
  return output;
2292
2292
  } catch (error) {
2293
- if (entry.kind.type === "step") {
2294
- entry.kind.data.error = String(error);
2295
- }
2296
- entry.dirty = true;
2297
2293
  if (error instanceof StepTimeoutError) {
2294
+ if (entry.kind.type === "step") {
2295
+ entry.kind.data.error = String(error);
2296
+ }
2297
+ entry.dirty = true;
2298
2298
  metadata.status = "exhausted";
2299
2299
  metadata.error = String(error);
2300
+ await this.flushStorage();
2300
2301
  await this.notifyStepError(config2, metadata.attempts, error, {
2301
2302
  willRetry: false
2302
2303
  });
@@ -2310,8 +2311,13 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2310
2311
  );
2311
2312
  }
2312
2313
  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;
2313
2318
  metadata.status = "exhausted";
2314
2319
  metadata.error = String(error);
2320
+ await this.flushStorage();
2315
2321
  await this.notifyStepError(config2, metadata.attempts, error, {
2316
2322
  willRetry: false
2317
2323
  });
@@ -2324,9 +2330,14 @@ var WorkflowContextImpl = class _WorkflowContextImpl {
2324
2330
  })
2325
2331
  );
2326
2332
  }
2333
+ if (entry.kind.type === "step") {
2334
+ entry.kind.data.error = String(error);
2335
+ }
2336
+ entry.dirty = true;
2327
2337
  const willRetry = metadata.attempts <= maxRetries;
2328
2338
  metadata.status = willRetry ? "failed" : "exhausted";
2329
2339
  metadata.error = String(error);
2340
+ await this.flushStorage();
2330
2341
  if (willRetry) {
2331
2342
  const retryDelay = calculateBackoff(
2332
2343
  metadata.attempts,
@@ -4199,4 +4210,4 @@ export {
4199
4210
  runWorkflow,
4200
4211
  replayWorkflowFromStep
4201
4212
  };
4202
- //# sourceMappingURL=chunk-EAAPMGGE.js.map
4213
+ //# sourceMappingURL=chunk-CIDHCIH7.js.map