Support hackney v4 in EventStream - #79
Merged
Merged
Conversation
Collaborator
|
Thanks! |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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