7a3ab96d94
Summary:
I discovered this while trying to pinpoint why Nuclide Inspector integration with RN is so flaky. It turns out that, for some reason, if I create a `WebSocket` instance early enough (which I need to when setting up DevTools integration), and the connection is fast enough (which it is on localhost), the `websocketOpen` message may arrive earlier than an `onopen` event handler is registered, causing the `onopen` handler to never fire.
```
mkdir ~/my-server
cd ~/my-server
npm i ws
nano index.js
```
Paste this code:
```js
const ws = require('ws');
const wss = new ws.Server({
port: 8099
});
```
Run the server:
```js
node index.js
```
Now, inside React Native, paste right after [these lines](
|
||
---|---|---|
.. | ||
RCTWebSocket.xcodeproj | ||
__mocks__ | ||
__tests__ | ||
RCTSRWebSocket.h | ||
RCTSRWebSocket.m | ||
RCTWebSocketExecutor.h | ||
RCTWebSocketExecutor.m | ||
RCTWebSocketModule.h | ||
RCTWebSocketModule.m | ||
RCTWebSocketObserver.h | ||
RCTWebSocketObserver.m | ||
WebSocket.js | ||
WebSocketEvent.js | ||
WebSocketInterceptor.js |