Skip to content

Support hackney v4 in EventStream - #79

Merged
michelboaventura merged 1 commit into
devstopfix:mainfrom
grain-team:hackney-v4-compat
Jul 9, 2026
Merged

Support hackney v4 in EventStream#79
michelboaventura merged 1 commit into
devstopfix:mainfrom
grain-team:hackney-v4-compat

Conversation

@howleysv

@howleysv howleysv commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The mix.exs file declares support for any version of hackney ">= 0.0.0", but compilation fails on the newer 4.x versions of hackney because of breaking API changes. I've just updated the usage to handle both locations for this function and pick the right one at compile-time

@michelboaventura

Copy link
Copy Markdown
Collaborator

Thanks!

@michelboaventura
michelboaventura merged commit f1f33fc into devstopfix:main Jul 9, 2026
15 checks passed
holsee added a commit to holsee/ex_aws_bedrock that referenced this pull request Jul 10, 2026
hackney 4.x broke the async event-stream path in two runtime ways that
`Support hackney v4 in EventStream (devstopfix#79)` (a compile-time compat fix) did
not cover:

1. Over an ALPN-negotiated HTTP/2 connection, hackney 4.x async streaming
   never delivers `{:hackney_response, _}` messages to the caller, so the
   status/data receives block forever (no `after` clause). bedrock-runtime
   negotiates HTTP/2, so every streaming request hangs, 0 bytes. Force
   HTTP/1.1 via `protocols: [:http1]` (Bedrock's event-stream API serves
   HTTP/1.1 chunked anyway; the option is a no-op on hackney 1.x).

2. hackney 4.x async `post` returns a connection PID, not a Reference, so
   the `Stream.resource` next-fn guard `is_reference(ref)` never matched
   and raised FunctionClauseError right after the status. Accept both
   `is_reference(ref) or is_pid(ref)`.

Verified end-to-end against Bedrock (eu-west-1) for both
claude-sonnet-4-5 and claude-sonnet-4-6 invoke-with-response-stream.

Claude-Session: https://claude.ai/code/session_01VyskHuyxAuEEWimeeFAz4h
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.

2 participants