Skip to content

How to handle a connection closed by the client when streaming a response? #669

Closed
@joaquimadraz

Description

@joaquimadraz

I'm implementing a feature where I'm sending chunks of a CSV file from a stream and currently, I'm using Enum.into to traverse the stream into the connection.

I'm getting an error when the connection is closed on the client side:

** (MatchError) no match of right hand side value: {:error, :closed}
(plug) lib/plug/conn.ex:1239: anonymous fn/2 in Collectable.Plug.Conn.into/1

Looking into the Plug.Conn implementation of the Collectable protocol explains the error because there's only a match when things go well.

I was wondering what would be the best approach to handle the case when the connection is closed by the client.

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