A handled getWritable() failure still fails the step after its body returns

Open
#4,414 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Start in step/writable-stream.js and flushable-stream.js to trace how stream failures reach ctx.ops, then inspect runtime/step-executor.js and its opsSettled handling. Reproduce the failure with a world whose streams.write rejects with a 503 StreamError, and compare the available handling options in the issue. Done means a caught secondary stream failure no longer fails the step or discards its returned value, while unhandled failures retain current behavior.

Written by the indexing model from the issue text.

Description

Summary

A step that writes to getWritable() fails after its body returns whenever any write to that stream failed, even when the step body caught the write error and finished its own work. There is no way to mark a step stream as best-effort, so a transient platform fault on a secondary output turns a completed step into a failed one.

Versions

  • @workflow/core 5.0.0-beta.51
  • @workflow/world-vercel 5.0.0-beta.46

What happens

  1. The step body writes UI chunks to getWritable(). A PUT to /v2/runs/<run>/stream/<name> fails (for example Stream write failed: HTTP 503, or transport failure after 300005ms (UND_ERR_INFO)). world-vercel correctly doesn't retry the append (streamer.js, stream retry options skip 5xx because appends aren't idempotent).
  2. The step body catches the rejected writer.write(), stops writing to that stream, and finishes its real work (it persists the result elsewhere and settles billing). Then it returns normally.
  3. getWritable() pushed the flushable state's promise into ctx.ops (step/writable-stream.js: ctx.ops.push(state.promise)). The pipe failure rejects it (flushable-stream.js, flushablePipePerChunk catch → state.reject(err)).
  4. After the body returns, runtime/step-executor.js awaits Promise.all(ops) in the opsSettled race and rethrows every rejection except AbortError / ResponseAborted (isClientDisconnectError). So the step fails with the stream's error. With maxRetries: 0 the run ends failed, and anything the workflow does after the step (settling state, enqueueing analytics from the step's return value) never runs.

Result: the user-visible work is complete, but the run is recorded as failed and the step's return value is lost.

Expected

A way for a step to own the failure of a stream it wrote to. Any of these would work for us:

  • an option such as getWritable({ failStepOnError: false }) (or a best-effort mode) that keeps the stream out of the step's fatal ops;
  • an API to abandon or detach a writable after a handled failure, so its rejection no longer fails the step;
  • treating a stream failure the step body already observed (the writer's write() / close() rejected into user code) as handled.

Repro sketch

In a step: get a writer from getWritable(), write a few chunks, make a write fail at the sink (a world whose streams.write rejects with a StreamError of status 503 reproduces it), catch the rejection, release the lock, and return a value. The step fails with the stream error instead of completing with the value.

Dominant language
TypeScript
Stars
2.5k
Forks
401
Avg merge
1d 21h
Merged PRs (30d)
201

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel/workflow

All issues in vercel/workflow

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.