Skip to content
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

[BUG] Exception when receive messages from javascript #975

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

davidsdearaujo
Copy link

Sometimes Javascript is returning messages that are Map instead of String and it's throwing an exception.

Snapshot

image

@davidsdearaujo davidsdearaujo changed the title fix: handle received messages from javascript Exception when receive messages from javascript Aug 17, 2024
@davidsdearaujo davidsdearaujo changed the title Exception when receive messages from javascript [BUG] Exception when receive messages from javascript Aug 17, 2024
String handleJsMessage(Object? jsMessage) {
return switch (jsMessage) {
String message => message,
Map map => jsonEncode(map),
Copy link
Owner

Choose a reason for hiding this comment

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

if it's already a map, do we need to encode and decode ?

Copy link
Author

@davidsdearaujo davidsdearaujo Sep 26, 2024

Choose a reason for hiding this comment

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

This is not always a map... I'm encoding at this moment to make as less changes as possible in the existing logic

Copy link
Author

@davidsdearaujo davidsdearaujo Sep 28, 2024

Choose a reason for hiding this comment

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

I've separated this logic into two distinct handlers in this commit: Improve web controller's JS message deserialization

return switch (jsMessage) {
String message => message,
Map map => jsonEncode(map),
Object? data => throw Exception(
Copy link
Owner

Choose a reason for hiding this comment

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

Let's fail silently

Copy link
Author

@davidsdearaujo davidsdearaujo Sep 28, 2024

Choose a reason for hiding this comment

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

Implemented in this commit: refactor: fail silently when handleJsMessage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants