-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better handling of malformed messages #69
Conversation
…ng of when the message is malformed. Fixes #67
container: crystallang/crystal:${{ matrix.crystal_version }}-alpine | ||
container: crystallang/crystal:${{ matrix.crystal_version }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because Ameba tanks on 1.6.0 under alpine
end | ||
end | ||
|
||
it "ignores incorrect json structures" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! so do not consider what I commented on the issue lol
@@ -1,82 +1,118 @@ | |||
module Cable | |||
class Payload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhh now I see what you're saying about the payload on the connection, maybe I misunderstood the issue 🤦
this is cool for sure, even better with the performance boost 👏
…stead of generating a new one to ensure the result is always the same
Fixes #67
This PR refactors how the
Payload
is created in order to better handle when a message comes through with malformed data. It also gives us a bit of a performance boost by moving the Payload over to structs!Explanation
The current
Payload
makes a lot of assumptions about the shape of the JSON being parsed. It first assumes valid JSON is passed in, then assumes that the valid JSON is an Object. The handler generally just does a blanket JSON::ParsingError catch on this.Now if we get an empty string, we can just ignore it, and if the JSON structure is valid, it'll be a full serialized object we can pass around easier. If the Payload can't be deserialized, then we raise the serialized error and let the handler do as it does.