Skip to content

Streams aren't closed automatically when runs end #964

@rovo89

Description

@rovo89

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.

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