Skip to content

Send string messages as text frames in RCTReconnectingWebSocket - #60296

Merged
meta-codesync[bot] merged 1 commit into
react:mainfrom
BenziAhamed:export-D134534825
Nov 30, 2026
Merged

meta-codesync[bot] merged 1 commit into
react:mainfrom
BenziAhamed:export-D134534825

Conversation

@BenziAhamed

Copy link
Copy Markdown
Contributor

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

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
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 25, 2026
@meta-codesync

meta-codesync Bot commented Nov 25, 2026

Copy link
Copy Markdown

@BenziAhamed has exported this pull request. If you are a Meta employee, you can view the originating Diff in D134534825.

@javache javache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at 2bfe47985b15.

android: no capture

@meta-codesync
meta-codesync Bot merged commit fb747cb into react:main Nov 30, 2026
91 checks passed
@react-native-bot

Copy link
Copy Markdown
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?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants