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

[iOS] Crash in RCTWebSocketModule didFailWithError #29525

Closed
bertrandgressier opened this issue Jul 29, 2020 · 3 comments
Closed

[iOS] Crash in RCTWebSocketModule didFailWithError #29525

bertrandgressier opened this issue Jul 29, 2020 · 3 comments
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@bertrandgressier
Copy link

I reopen this issue #28278

Description

We're seeing some crashes in our Crashlytics dashboard with the following error:

Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]

coming from

RCTWebSocketModule.m
-[RCTWebSocketModule webSocket:didFailWithError:]

React Native version:

0.62.2

Steps To Reproduce

WebSocket errors

Expected Results

The app should not crash.

this person #28278 (comment) suggested a fix for this issue

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x1a1571344 (Manquant)
1  libobjc.A.dylib                0x1a1286cc0 (Manquant)
2  CoreFoundation                 0x1a15ca550 (Manquant)
3  CoreFoundation                 0x1a15d44c8 (Manquant)
4  CoreFoundation                 0x1a1458944 (Manquant)
5  CoreFoundation                 0x1a144a1c4 (Manquant)
6  gotoconnect                    0x10010b874 -[RCTWebSocketModule webSocket:didFailWithError:] + 175 (RCTWebSocketModule.mm:175)
7  gotoconnect                    0x100638a3c __33-[RCTSRWebSocket _failWithError:]_block_invoke_2 + 619 (RCTSRWebSocket.m:619)
8  libdispatch.dylib              0x1a1212134 (Manquant)
9  libdispatch.dylib              0x1a12135ac (Manquant)
10 libdispatch.dylib              0x1a121f7d4 (Manquant)
11 CoreFoundation                 0x1a14ec8d4 (Manquant)
12 CoreFoundation                 0x1a14e758c (Manquant)
13 CoreFoundation                 0x1a14e6bc8 (Manquant)
14 GraphicsServices               0x1ab8c85cc (Manquant)
15 UIKitCore                      0x1a5699744 (Manquant)
16 gotoconnect                    0x1000d6d04 main + 28 (AppDelegate.swift:28)
17 libdyld.dylib                  0x1a1363384 (Manquant)
@chrisglein
Copy link

@bertrandgressier Sounds like you have a patch available through the original bug, and it seems pretty localized. Why not submit a PR with that fix?

facebook-github-bot pushed a commit that referenced this issue Oct 12, 2020
Summary:
This PR attempts to fix issue #28278 and #29525

On Crashlytics, the following error occurs in file `RCTWebSocketModule.m` at method `-[RCTWebSocketModule webSocket:didFailWithError:]` when a nil value is inserted into a dictionary as a value.

```
Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
```

This PR is following the suggestion of this: #28278 (comment) and it replaces the values of any property if it is nil. In detail:
- it converts `error` to empty NSString if the original value is nil
- it converts `socketID` to a NSNumber object, which stores `-1` if the original value is nil

## Changelog

[iOS] [Fixed] - A crash in WebSocket module

Pull Request resolved: #30066

Test Plan: We were not able to reproduce the crash, but the report itself provided enough information to find a solution for this issue.

Reviewed By: shergin

Differential Revision: D24241147

Pulled By: sammy-SC

fbshipit-source-id: d5d632b49ca77b5d8be8b9c32358bef68f17d30a
kelset pushed a commit that referenced this issue Nov 27, 2020
Summary:
This PR attempts to fix issue #28278 and #29525

On Crashlytics, the following error occurs in file `RCTWebSocketModule.m` at method `-[RCTWebSocketModule webSocket:didFailWithError:]` when a nil value is inserted into a dictionary as a value.

```
Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
```

This PR is following the suggestion of this: #28278 (comment) and it replaces the values of any property if it is nil. In detail:
- it converts `error` to empty NSString if the original value is nil
- it converts `socketID` to a NSNumber object, which stores `-1` if the original value is nil

## Changelog

[iOS] [Fixed] - A crash in WebSocket module

Pull Request resolved: #30066

Test Plan: We were not able to reproduce the crash, but the report itself provided enough information to find a solution for this issue.

Reviewed By: shergin

Differential Revision: D24241147

Pulled By: sammy-SC

fbshipit-source-id: d5d632b49ca77b5d8be8b9c32358bef68f17d30a
brentvatne pushed a commit to expo/react-native that referenced this issue Dec 3, 2020
Summary:
This PR attempts to fix issue facebook#28278 and facebook#29525

On Crashlytics, the following error occurs in file `RCTWebSocketModule.m` at method `-[RCTWebSocketModule webSocket:didFailWithError:]` when a nil value is inserted into a dictionary as a value.

```
Fatal Exception: NSInvalidArgumentException
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
```

This PR is following the suggestion of this: facebook#28278 (comment) and it replaces the values of any property if it is nil. In detail:
- it converts `error` to empty NSString if the original value is nil
- it converts `socketID` to a NSNumber object, which stores `-1` if the original value is nil

## Changelog

[iOS] [Fixed] - A crash in WebSocket module

Pull Request resolved: facebook#30066

Test Plan: We were not able to reproduce the crash, but the report itself provided enough information to find a solution for this issue.

Reviewed By: shergin

Differential Revision: D24241147

Pulled By: sammy-SC

fbshipit-source-id: d5d632b49ca77b5d8be8b9c32358bef68f17d30a
@stale
Copy link

stale bot commented Dec 26, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Dec 26, 2020
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

3 participants