Skip to content

Commit

Permalink
fix(sync-server): Fix error that occurs when /shape response stream…
Browse files Browse the repository at this point in the history
… is closed before it is complete (#1489)

This closes #1440
  • Loading branch information
robacourt authored Aug 7, 2024
1 parent 3a412bf commit d24993b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/fifty-frogs-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@core/sync-service": patch
---

Fix error that occurs when a `/shape` response stream is closed before it is complete,
for example when `curl --head` is used to call the endpoint.
6 changes: 5 additions & 1 deletion packages/sync-service/lib/electric/plug/serve_shape_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,11 @@ defmodule Electric.Plug.ServeShapePlug do
{:ok, conn} ->
{:cont, conn}

{:error, :closed} ->
{:error, "closed"} ->
{:halt, conn}

{:error, reason} ->
Logger.error("Error while streaming response: #{inspect(reason)}")
{:halt, conn}
end
end)
Expand Down

0 comments on commit d24993b

Please sign in to comment.