react-native: Regression on 0.55.0 crash: WebSocketModule.close got 1 arguments, expected 3

Closing a websocket crashes the app

Environment

$ react-native info
Scanning folders for symlinks in /media/dj/dev/scan-app/node_modules (9ms)

Environment:
  OS: Linux 4.13
  Node: 9.10.1
  Yarn: Not Found
  npm: 5.6.0
  Watchman: 4.7.0
  Xcode: N/A
  Android Studio: Not Found

Packages: (wanted => installed)
  react: ^16.3.0-rc.0 => 16.3.0-rc.0
  react-native: ^0.55.0 => 0.55.0

Steps to Reproduce

  1. open websocket connection. example:
const ws = new WebSocket(makeSocketURL())
  1. close websocket connection. example:
ws.close()

Expected Behavior

the websocket connection closes, no error

Actual Behavior

Logcat:

--------- beginning of crash
04-04 14:28:15.716 19745 19780 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
04-04 14:28:15.716 19745 19780 E AndroidRuntime: Process: com.chipta, PID: 19745
04-04 14:28:15.716 19745 19780 E AndroidRuntime: com.facebook.react.bridge.NativeArgumentsParseException: WebSocketModule.close got 1 arguments, expected 3
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:353)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:754)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:95)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:163)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
04-04 14:28:15.716 19745 19780 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:760)
04-04 14:28:16.322 19745 19745 D ReactNative: ReactInstanceManager.detachViewFromInstance()

related: https://github.com/facebook/react-native/issues/18623

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 22 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I just installed the current latest version "react-native": "^0.55.3" and (magically 😄 ) the problem disappeared.

Please release v0.55.3 to fixed this

To discuss cherry-picks and critical things, there’s a dedicated repo with a dedicated issue (this).

We’ll keep you updated.

In the meantime I think pinging @rozele to know more about his commit is a good approach.

I’m still experiencing WebSocketModule.close got 1 arguments, expected 3 on React native version 0.55.4. Using expo sdk 28.0.1. Anyone else having this issue?

@vahanNasibyan, this is what I did:

In your package.json file, declare the postinstall script:

  "scripts": {
    "start": "watchman watch-del-all && (adb reverse tcp:3000 tcp:3000 || true) && node node_modules/react-native/local-cli/cli.js start --reset-cache",
    "test": "jest",
    "postinstall": "scripts/third-party-boo-boos.sh"
  },

In a scripts folder in root directory, I have a script third-party-boo-boos.sh:

#!/usr/bin/env bash
# Catch all script to fix/patch boo-boos in third-party libraries

# For RN 0.55.0 and up
# Download patch file and patch Websocket.js
wget https://github.com/facebook/react-native/commit/4b6e9d3dfd213689c5b319a4efee8d4f606d6f9d.patch
patch $PWD/node_modules/react-native/Libraries/WebSocket/WebSocket.js 4b6e9d3dfd213689c5b319a4efee8d4f606d6f9d.patch
rm -f 4b6e9d3dfd213689c5b319a4efee8d4f606d6f9d.patch

Delete your node_modules and reinstall them with npm install or yarn

This is still an issue on RN-0.55.2. This is a very serious issue! Why was this closed?

https://github.com/facebook/react-native/commit/b9be289 is definitely causing this issue, since WebSocketModule.close.length is always returning 0, which results in passing always only 1 parameter to close().

Since this really is a severe bug, causing the entire app to crash and not to respond whenever one tries to close a websocket connection, I hope someone from the react-native team is going to revert the referenced commit and publish 0.55.1 version as soon as possible. Maybe @hramos?

@ujwal-setlur The fix is merged to master and a request was put in to cherry-pick it for RN 0.55.3.

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.54?

Thank you for your contributions.