Skip to content

Not expected behaviour in #25

@tkowalczyk

Description

@tkowalczyk

Using code from example:

export const getWorkflowStatus: RouteEffect<Response> = Effect.gen(function* () {
    const c = yield* HonoCtx;
    const env = yield* CloudflareEnv;
  
    const instanceId = c.req.param("id");
    const client = WorkflowClient.fromBinding(env.WORKFLOWS);
  
    const status = yield* client.status(instanceId);
  
    return c.json({
      instanceId,
      status,
    });
  });

When Effect.fail in one of the step:

const mvrv = yield* Workflow.step("MVRV",
            fetchMVRVIdempotent(taskId)
                .pipe(
                    Effect.catchTag("FetchError", (error) =>
                        Effect.fail(
                            new MVRVFailed({ reason: `Status Code: ${error.status}`, taskId: taskId }))
                    ),
                ));

and we have Effect.catchAll:

.pipe(
            Effect.catchAll((error) =>
                Effect.gen(function* () {
                    const ctx = yield* WorkflowContext;
                    yield* ctx.setMeta("error", String(error));
                    yield* Effect.logError("Workflow failed", error);
                })
            )),

under http://localhost:8788/workflows/fetchOnChain:task-1765393265162/status

I am getting wrong in my opinion response:

{
  "instanceId": "fetchOnChain:task-1765393265162",
  "status": {
    "completedAt": 1765393265410,
    "_tag": "Completed"
  }
}

because workflow failed:

[wrangler:info] GET /workflows/sentiment/onchain 200 OK (25ms)
timestamp=2025-12-10T19:01:05.188Z level=INFO fiber=#132 message="Processing workflow {
  \"_id\": \"Effect\",
  \"_op\": \"OnSuccess\",
  \"effect_instruction_i0\": {
    \"_id\": \"Effect\",
    \"_op\": \"OnFailure\",
    \"effect_instruction_i0\": {
      \"_id\": \"Effect\",
      \"_op\": \"OnSuccess\",
      \"effect_instruction_i0\": {
        \"_id\": \"Effect\",
        \"_op\": \"OnSuccess\",
        \"effect_instruction_i0\": {
          \"_id\": \"Effect\",
          \"_op\": \"Sync\"
        }
      }
    }
  }
}, with id {
  \"_id\": \"Exit\",
  \"_tag\": \"Success\",
  \"value\": \"b6e0552a9930a43b7ade51c0fc3ae22fe57c2891deaea9943eed39e5dac5473f\"
}"
timestamp=2025-12-10T19:01:05.189Z level=INFO fiber=#132 message="Fetching data for step MVRV"
timestamp=2025-12-10T19:01:05.403Z level=INFO fiber=#132 message="Response: 429, false"
timestamp=2025-12-10T19:01:05.407Z level=ERROR fiber=#132 message="Workflow failed" message="{
  \"reason\": \"Status Code: 429\",
  \"taskId\": \"task-1765393265162\",
  \"_tag\": \"MVRVFailed\"
}"

but without:

.pipe(
            Effect.catchAll((error) =>
                Effect.gen(function* () {
                    const ctx = yield* WorkflowContext;
                    yield* ctx.setMeta("error", String(error));
                    yield* Effect.logError("Workflow failed", error);
                })
            )),

of course on different workflow id: http://localhost:8788/workflows/fetchOnChain:task-1765393767796/status
returns better result:

{
  "instanceId": "fetchOnChain:task-1765393767796",
  "status": {
    "failedAt": 1765393768007,
    "error": {
      "message": "",
      "stack": "MVRVFailed\n    at file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:34352:13\n    at EffectPrimitive.effect_instruction_i1 (file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:12242:40)\n    at file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:19697:44\n    at effect_internal_function (file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:1975:12)\n    at FiberRuntime.Failure (file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:19697:20)\n    at file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:19854:31\n    at Object.context (file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:14339:42)\n    at FiberRuntime.runLoop (file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:19846:34)\n    at FiberRuntime.evaluateEffect (file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:19477:28)\n    at FiberRuntime.evaluateMessageWhileSuspended (file:///Users/tkow/Documents/Code/span-fund/workers/sf-report/.wrangler/tmp/dev-ekTlVP/index.js:19454:14)"
    },
    "_tag": "Failed"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions