Skip to content

Comments

fix: prevent crash when logging channel termination reason#1696

Merged
edgurgel merged 1 commit intosupabase:mainfrom
darfink:patch-1
Feb 4, 2026
Merged

fix: prevent crash when logging channel termination reason#1696
edgurgel merged 1 commit intosupabase:mainfrom
darfink:patch-1

Conversation

@darfink
Copy link
Contributor

@darfink darfink commented Feb 3, 2026

What kind of change does this PR introduce?

Bug fix to prevent crash when logging channel termination reason.

What is the current behavior?

An error is thrown when logging the termination reason if it's a tuple (e.g. {:shutdown, :left}).

[error] GenServer #PID<0.3906.0> terminating
** (Protocol.UndefinedError) protocol String.Chars not implemented for type Tuple. This protocol is implemented for the following type(s): Atom, BitString, Date, DateTime, Decimal, ExJsonSchema.Schema.Ref, ExJsonSchema.Validator.Error.AdditionalItems, ExJsonSchema.Validator.Error.AdditionalProperties, ExJsonSchema.Validator.Error.AllOf, ExJsonSchema.Validator.Error.AnyOf, ExJsonSchema.Validator.Error.Const, ExJsonSchema.Validator.Error.Contains, ExJsonSchema.Validator.Error.ContentEncoding, ExJsonSchema.Validator.Error.ContentMediaType, ExJsonSchema.Validator.Error.Dependencies, ExJsonSchema.Validator.Error.Enum, ExJsonSchema.Validator.Error.False, ExJsonSchema.Validator.Error.Format, ExJsonSchema.Validator.Error.IfThenElse, ExJsonSchema.Validator.Error.ItemsNotAllowed, ExJsonSchema.Validator.Error.MaxItems, ExJsonSchema.Validator.Error.MaxLength, ExJsonSchema.Validator.Error.MaxProperties, ExJsonSchema.Validator.Error.Maximum, ExJsonSchema.Validator.Error.MinItems, ExJsonSchema.Validator.Error.MinLength, ExJsonSchema.Validator.Error.MinProperties, ExJsonSchema.Validator.Error.Minimum, ExJsonSchema.Validator.Error.MultipleOf, ExJsonSchema.Validator.Error.Not, ExJsonSchema.Validator.Error.OneOf, ExJsonSchema.Validator.Error.Pattern, ExJsonSchema.Validator.Error.PropertyNames, ExJsonSchema.Validator.Error.Required, ExJsonSchema.Validator.Error.Type, ExJsonSchema.Validator.Error.UniqueItems, Float, Integer, List, NaiveDateTime, OpenApiSpex.Cast.Error, Phoenix.LiveComponent.CID, Postgrex.Copy, Postgrex.Query, Time, URI, Version, Version.Requirement

Got value:

    {:shutdown, :left}

    (elixir 1.18.4) lib/string/chars.ex:3: String.Chars.impl_for!/1
    (elixir 1.18.4) lib/string/chars.ex:22: String.Chars.to_string/1
    (realtime 2.74.2) lib/realtime_web/channels/realtime_channel.ex:512: RealtimeWeb.RealtimeChannel.terminate/2
    (stdlib 6.2.1) gen_server.erl:2393: :gen_server.try_terminate/3
    (stdlib 6.2.1) gen_server.erl:2594: :gen_server.terminate/10
    (stdlib 6.2.1) proc_lib.erl:340: :proc_lib.wake_up/3

What is the new behavior?

The logging adopts the same convention as other Phoenix terminate handlers using inspect.

Additional context

We observed frequent GenServer crashes on channel disconnects. My troubleshooting identified this log line as the culprit.

Copy link
Member

@edgurgel edgurgel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@edgurgel edgurgel merged commit d8ef682 into supabase:main Feb 4, 2026
6 of 11 checks passed
@kiwicopple
Copy link
Member

🎉 This PR is included in version 2.74.6 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants