Repository navigation
Send string messages as text frames in RCTReconnectingWebSocket - #60296
Merged
Merged
Conversation
Summary:
`RCTReconnectingWebSocket -send:` takes `id` but always forwarded it to SocketRocket's `sendData:error:`, which calls `-bytes` on its argument. Its only callers, `RCTPackagerClientResponder -respondWithResult:` and `-respondWithError:`, pass an `NSString` built with `RCTJSONStringify`. So whenever the packager connection answered a request, the app aborted with an unrecognized selector (`-[__NSCFString bytes]`).
The packager connection treats any incoming message with a top-level `id` as a request and always replies, even when no handler is registered for the method ("No handler found for packager method …"). A single request reaching the app's packager socket through the dev server therefore crashed a debug iOS app.
`-send:` now sends an `NSString` with `sendString:error:` (a text frame, which is what the dev server expects for JSON) and anything else with `sendData:error:` as before.
Changelog:
[iOS][Fixed] - Fix a crash when the packager connection replies to a request from the dev server
Differential Revision: D134534825
|
@BenziAhamed has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134534825. |
javache
approved these changes
Nov 27, 2026
javache
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Visual regressionNo visual differences at android: no capture |
Collaborator
|
This pull request was successfully merged by @BenziAhamed in fb747cb When will my fix make it into a release? | How to file a pick request? |
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.
Summary:
RCTReconnectingWebSocket -send:takesidbut always forwarded it to SocketRocket'ssendData:error:, which calls-byteson its argument. Its only callers,RCTPackagerClientResponder -respondWithResult:and-respondWithError:, pass anNSStringbuilt withRCTJSONStringify. So whenever the packager connection answered a request, the app aborted with an unrecognized selector (-[__NSCFString bytes]).The packager connection treats any incoming message with a top-level
idas a request and always replies, even when no handler is registered for the method ("No handler found for packager method …"). A single request reaching the app's packager socket through the dev server therefore crashed a debug iOS app.-send:now sends anNSStringwithsendString:error:(a text frame, which is what the dev server expects for JSON) and anything else withsendData:error:as before.Changelog:
[iOS][Fixed] - Fix a crash when the packager connection replies to a request from the dev server
Differential Revision: D134534825