Skip to content

Wrap hackney:close in try/catch to prevent crash when ETS table is gone#3

Open
p424p424 wants to merge 1 commit into
violetbuse:masterfrom
p424p424:master
Open

Wrap hackney:close in try/catch to prevent crash when ETS table is gone#3
p424p424 wants to merge 1 commit into
violetbuse:masterfrom
p424p424:master

Conversation

@p424p424

@p424p424 p424p424 commented Jul 9, 2026

Copy link
Copy Markdown

When the streaming process calls hackney:close/1 during cleanup, hackney's connection-manager ETS table may already have been torn down by another process, causing a bad argument crash in ets:lookup/2.

This is a race condition — it happens intermittently, always after the stream has finished and the response has been delivered, so it's cosmetic (exit code is still 0). But it produces a scary-looking CRASH REPORT in the terminal.

The fix wraps the close call in a try/catch, matching the pattern already used throughout hackney itself for similar cleanup operations.

Before

close(ClientRef) ->
  hackney:close(ClientRef),
  nil.

After

close(ClientRef) ->
  try hackney:close(ClientRef) catch _:_ -> ok end,
  nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant