fix(gun): map connection-level gun errors to internal status#548
Merged
polvalente merged 2 commits intoJun 30, 2026
Merged
Conversation
polvalente
approved these changes
Jun 30, 2026
polvalente
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution (with thorough tests!)
@sleipnir I believe we should treat this as a simple bugfix instead of a breaking change even if there are implicit contract changes (and users can easily handle the new response as needed)
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.
Problem
The Gun adapter reports some connection errors as
GRPC.Status.unknown().For example:
{:gun_error, conn_pid, reason}to the stream response process.StreamResponseProcesstreats it as an unexpected message.GRPC.Status.unknown()instead of a connection error.UNKNOWNis the wrong status here because the adapter has already received a concrete Gun connection error. Exposing it asUNKNOWNloses that information and makes the failure look like an unexpected adapter message instead of a transport error. Userland code handling gRPC errors then only sees opaque status2, even though Gun reported a connection-level failure. In our case we decide if a request is retriable based on this, and would not want to broaden it toUNKNOWNunnecessarily.Root cause
StreamResponseProcesshandles stream-level Gun errors with a stream ref:but not connection-level Gun errors without a stream ref:
The connection-level message falls through to
unexpected_message, even though Gun's own await helpers classify the same message asconnection_error.Fix
Keep the fix scoped to the Gun adapter.
{:connection_error, reason}{:stream_error, reason}With this change, connection-level Gun errors returned through
reply_tomap toGRPC.Status.internal()instead ofGRPC.Status.unknown().Test plan
await/2await/2is waiting