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

App crashes when triggering an event with map data on a private channel #171

Open
Phelickz opened this issue Sep 13, 2024 · 1 comment
Open

Comments

@Phelickz
Copy link

Phelickz commented Sep 13, 2024

Hi there

Bug Report: App crashes when triggering event with a map data type on private channel

Description

I get this error when I try to trigger an event for a private channel:

Could not cast value of type '__NSDictionaryM' (0x10e189548) to 'NSString' (0x10e1819f0).

After this error, the app crashes.

Code Sample

Here is the code I'm using that causes the error:

await _pusher.trigger(
    PusherEvent(
        channelName: 'private-$channelId', 
        eventName: 'client-$event', 
        data: { 'some': 'map', 'data': 'example' },
    ),
);

If I use a string instead of a map for the data parameter, no error is thrown, and the event works fine:

await _pusher.trigger(
    PusherEvent(
        channelName: 'private-$channelId', 
        eventName: 'client-$event', 
        data: 'some string',
    ),
);

Additional Information

  • Subscription to the channel was successful:
LOG: onEvent: { channelName: private-77a90cc0-a3a6-4d35-a7bc-ba8abaacd8eb, eventName: pusher:subscription_succeeded, data: {}, userId: null }

Expected Behavior

The data parameter for the triggerEvent method is of dynamic type, so I assume it should accept different data types, including maps. I expect that using a map for data shouldn't crash the app. Ideally, the framework should handle the error or throw an exception instead of causing a crash.

Wrapping the code in a try-catch block did not help in catching the error.

Environment

  • Platform: [iOS]
  • Framework: [2.2.1]
  • Language: Dart/Flutter
@Phelickz
Copy link
Author

Also to add that I could just easily json encode the map data, but I wanted to bring it to your notice that some native platform errors are causing the app to crash.

It also happened when I was trying to join a private channel. If my backend throws an error and the authorizer doesn't complete, my app crashes. Using a try-catch block does not help. Please fix.

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

No branches or pull requests

1 participant