Serialize error reason as JSON#3984
Merged
SteffenDE merged 1 commit intophoenixframework:mainfrom Sep 16, 2025
Merged
Conversation
Based on the fact that Phoenix Channels use a JSON-based serializer [1],
assume the error reason is a JSON-serializable object.
Without this step, we get JavaScript's native string representation of
the value, which leads to unhelpful error messages such as:
failed with reason: [object Object]
instead of
failed with reason: {"reason":"unmatched topic"}
[1]: https://hexdocs.pm/phoenix/1.8.1/writing_a_channels_client.html#message-format
3f0a873 to
499b350
Compare
Contributor
Author
|
Rebased against latest I've been running this patch in production for ~2 weeks and have not seen any case of unserializable data attempting to go into the error message. It has had the benefit of going from |
Collaborator
|
Yeah, I think it's good :) |
SteffenDE
pushed a commit
that referenced
this pull request
Sep 18, 2025
Based on the fact that Phoenix Channels use a JSON-based serializer [1],
assume the error reason is a JSON-serializable object.
Without this step, we get JavaScript's native string representation of
the value, which leads to unhelpful error messages such as:
failed with reason: [object Object]
instead of
failed with reason: {"reason":"unmatched topic"}
[1]: https://hexdocs.pm/phoenix/1.8.1/writing_a_channels_client.html#message-format
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.
Based on the fact that Phoenix Channels use a JSON-based serializer 1, assume the error reason is a JSON-serializable object.
Without this step, we get JavaScript's native string representation of the value, which leads to unhelpful error messages such as:
instead of