@redflow/client 0.0.4 → 0.0.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redflow/client",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
package/src/client.ts CHANGED
@@ -16,16 +16,17 @@ import { keys } from "./internal/keys";
16
16
  import { safeJsonParse, safeJsonStringify, safeJsonTryParse } from "./internal/json";
17
17
  import { nowMs } from "./internal/time";
18
18
  import { sleep } from "./internal/sleep";
19
- import type {
20
- EmitWorkflowOptions,
21
- ListedRun,
22
- ListRunsParams,
23
- RunHandle,
24
- RunOptions,
25
- RunState,
26
- RunStatus,
27
- StepState,
28
- WorkflowMeta,
19
+ import {
20
+ DEFAULT_MAX_ATTEMPTS,
21
+ type EmitWorkflowOptions,
22
+ type ListedRun,
23
+ type ListRunsParams,
24
+ type RunHandle,
25
+ type RunOptions,
26
+ type RunState,
27
+ type RunStatus,
28
+ type StepState,
29
+ type WorkflowMeta,
29
30
  } from "./types";
30
31
  import type { WorkflowRegistry } from "./registry";
31
32
 
@@ -392,7 +393,7 @@ export class RedflowClient {
392
393
  ? Math.floor(options.__maxAttemptsOverride)
393
394
  : null;
394
395
 
395
- const maxAttempts = maxAttemptsOverride ?? (await this.getMaxAttemptsForWorkflow(workflowName)) ?? 1;
396
+ const maxAttempts = maxAttemptsOverride ?? (await this.getMaxAttemptsForWorkflow(workflowName)) ?? DEFAULT_MAX_ATTEMPTS;
396
397
 
397
398
  return await this.enqueueRun<TOutput>({
398
399
  workflowName,
@@ -468,7 +469,7 @@ export class RedflowClient {
468
469
  output,
469
470
  error,
470
471
  attempt: Number(data.attempt ?? "0"),
471
- maxAttempts: Number(data.maxAttempts ?? "1"),
472
+ maxAttempts: Number(data.maxAttempts ?? String(DEFAULT_MAX_ATTEMPTS)),
472
473
  createdAt: Number(data.createdAt ?? "0"),
473
474
  availableAt: data.availableAt ? Number(data.availableAt) : undefined,
474
475
  startedAt: data.startedAt ? Number(data.startedAt) : undefined,
package/src/types.ts CHANGED
@@ -12,8 +12,10 @@ export type CronTrigger = {
12
12
  id?: string;
13
13
  };
14
14
 
15
+ export const DEFAULT_MAX_ATTEMPTS = 3;
16
+
15
17
  export type WorkflowRetries = {
16
- /** Total attempts including the first one. Default: 1 (no retries). */
18
+ /** Total attempts including the first one. Default: 3. */
17
19
  maxAttempts?: number;
18
20
  };
19
21
 
package/src/worker.ts CHANGED
@@ -16,7 +16,7 @@ import { safeJsonParse, safeJsonStringify, safeJsonTryParse } from "./internal/j
16
16
  import { sleep } from "./internal/sleep";
17
17
  import { nowMs } from "./internal/time";
18
18
  import { getDefaultRegistry, type WorkflowRegistry } from "./registry";
19
- import type { OnFailureContext, RunStatus, StepApi, StepStatus } from "./types";
19
+ import { DEFAULT_MAX_ATTEMPTS, type OnFailureContext, type RunStatus, type StepApi, type StepStatus } from "./types";
20
20
 
21
21
  export type StartWorkerOptions = {
22
22
  /** Stable application id used for registry sync stale-cleanup scoping. */
@@ -419,7 +419,7 @@ async function processRun(args: {
419
419
  const workflowName = run.workflow ?? "";
420
420
  const def = workflowName ? registry.get(workflowName) : undefined;
421
421
  const maxConcurrency = normalizeMaxConcurrency(def?.options.maxConcurrency);
422
- const maxAttempts = Number(run.maxAttempts ?? "1");
422
+ const maxAttempts = Number(run.maxAttempts ?? String(DEFAULT_MAX_ATTEMPTS));
423
423
  const cancelRequestedAt = run.cancelRequestedAt ? Number(run.cancelRequestedAt) : 0;
424
424
  if (cancelRequestedAt > 0) {
425
425
  await client.finalizeRun(runId, { status: "canceled", finishedAt: nowMs() });