Skip to content

Commit

Permalink
Properly surface socket level errors on Plug.Conn.chunk/2 calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrudel committed Nov 29, 2024
1 parent cc206b0 commit 9dbc816
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/bandit/adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ defmodule Bandit.Adapter do
{:ok, nil, send_data(adapter, encoded_chunk, false)}
end
rescue
error in Bandit.SocketError -> {:error, error.socket_error}
error -> {:error, Exception.message(error)}
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/bandit/http1/request_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2448,7 +2448,7 @@ defmodule HTTP1RequestTest do
conn = send_chunked(conn, 200)

Process.sleep(200)
assert chunk(conn, "IMPOSSIBLE") == {:error, "closed"}
assert chunk(conn, "IMPOSSIBLE") == {:error, :closed}

conn
end
Expand Down

0 comments on commit 9dbc816

Please sign in to comment.