React Native Packager sometimes crashes with WebSocket "ERROR not opened"
See original GitHub issueDescription
When developing an app and reloading the iOS simulator, occasionally the react native packager will crash, and I have to restart it.
Here is the output from my console:
Bundling `index.ios.js`
No module changed.
Bundling `index.ios.js`
No module changed.
Bundling `index.ios.js`
No module changed.
ERROR not opened
Error: not opened
at WebSocket.send (/Users/ndbroadbent/code/myapp/node_modules/ws/lib/WebSocket.js:219:16)
at Server.packagerServer.setHMRFileChangeListener [as _hmrFileChangeListener] (/Users/ndbroadbent/code/myapp/node_modules/react-native/local-cli/server/util/attachHMRServer.js:149:21)
at Server.onFileChange (/Users/ndbroadbent/code/myapp/node_modules/react-native/packager/react-packager/src/Server/index.js:406:12)
at Server.processFileChange (/Users/ndbroadbent/code/myapp/node_modules/react-native/packager/react-packager/src/Server/index.js:236:40)
at Array.forEach (native)
at HasteMap.dependencyGraph.getWatcher.on (/Users/ndbroadbent/code/myapp/node_modules/react-native/packager/react-packager/src/Server/index.js:261:40)
at emitOne (events.js:101:20)
at HasteMap.emit (events.js:188:7)
at Timeout.emitChange [as _repeat] (/Users/ndbroadbent/code/myapp/node_modules/jest-haste-map/build/index.js:558:14)
at Timeout.wrapper [as _onTimeout] (timers.js:425:11)
See http://facebook.github.io/react-native/docs/troubleshooting.html
for common problems and solutions.
Reproduction Steps and Sample Code
This happens when I press CMD+R to reload the iOS simulator, but it only happens once every few hours. Sometimes just once a day.
Solution
Catch the error, and just ignore it instead of crashing.
Workaround
I’ve just been running: while true; do react-native start; done
Additional Information
- React Native version: 0.41.2
- Platform: iOS
- Development Operating System: MacOS
- Dev tools: XCode 8.2.1, iOS 8.4 Simulator.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:80
- Comments:55 (2 by maintainers)
Top Results From Across the Web
react native reloading is not working - Stack Overflow
I made a new react-native project with "react-native init" today. I changed some text in App class and reloaded simulator, then modification ...
Read more >Common errors | npm Docs
It's most likely a temporary npm registry glitch. Check npm server status and try again later. If the error persists, perhaps the published...
Read more >Firebase Apple SDK Release Notes - Google
When upgrading a project that includes one or more of these libraries, an error like Missing package product 'FirebaseSwift-Beta' will appear.
Read more >websocket was closed before the connection was established - You ...
So, the cause of this error is if code attempts to close the WebSocket connection before it's had a chance to actually connect....
Read more >Troubleshooting Node.js Deploys - Heroku Dev Center
In order to update the package-lock.json , run npm install and check in the changes to the file to git. yarn. To update...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i thought the websockets required an error handle but the problem was fixed just by cleaning cache
npm start -- --reset-cache
+1 driving me crazy