-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Closed
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
WebSocket client doesn't currently contain any handling for binary messages and just passes the message directly to bridge. This crashes the application.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (_NSInlineData)'
Problematic code:
react-native/Libraries/WebSocket/RCTWebSocketManager.m
Lines 83 to 89 in 0c9c6e8
| - (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message | |
| { | |
| [_bridge.eventDispatcher sendDeviceEventWithName:@"websocketMessage" body:@{ | |
| @"data": message, | |
| @"id": webSocket.reactTag | |
| }]; | |
| } |
Few ways to fix this.
- Wait for [Bridge] Array Buffers / Typed Arrays for WebSockets, Ajax #1424
- Pass error describing the issue instead of crashing
- Convert NSData to string
- Base64 encode NSData and convert to arraybuffer & blob in JS
Personally I'd prefer 4. as it brings the polyfill api more closer to actual WebSocket behaviour. I can take a stab at the problem once we've settled with the correct approach.
Thanks!
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.