Streams aren't closed automatically when runs end
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 365
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 169
Description
https://useworkflow.dev/docs/foundations/streaming#best-practices says:
Streams are automatically closed when the workflow run completes, but explicitly closing them signals completion to consumers earlier.
Which I think it makes sense, because nothing could be written anymore after that point. The suggested finalizeStream() might make sense to close streams after the last planned write, especially if there are further steps afterwards, but otherwise it's boilerplate code that I'd like to avoid. Keep in mind that we would need to handle errors as well, so it would be a try -> catch -> finalizeStream() -> rethrow, but only if it's a fatal error or the last retry (which can get very complex to evaluate), ... And none of that would be able to handle cancelled runs (via the web UI). It also requires book-keeping of used streams and adds noise to the event log / step list / ...
Therefore, I'd really appreciate if runs transitioning into a terminal state would automatically close all their streams.
The docs already say so, but in my tests on both local and Postgres world, no EOF entry was written, whether its for successfully completed or failed runs.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the streaming best-practices documentation and reproduce the reported behavior for successful and failed runs in both local and Postgres setups. Trace how terminal workflow states and stream events are handled; done means terminal runs produce the expected EOF entry, including failures, without requiring manual finalization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgres, typescript
- Domain
- databases, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100