jk-gan / redux-flipper

Redux middleware for React Native for Flipper
MIT License
158 stars 21 forks source link

Unhandled exception if Flipper disconnects while client is sending actions #49

Closed jakobo closed 2 years ago

jakobo commented 2 years ago

Summary

When the flipper client temporarily disconnects, an Unhandled Exception occurs.

Reproduction

  1. Install flipper as normal
  2. Connect and receive redux events
  3. Close flipper, send another redux action from the app

expected Actions work as expected

actual

[Unhandled promise rejection: Error: Cannot send data, not connected]
at node_modules/react-native-flipper/index.js:45:12 in Connection#send
at node_modules/redux-flipper/lib/index.js:74:16 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1319:29 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1217:29 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1177:25 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1091:29 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1040:25 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1002:29 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1376:29 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/query/rtk-query.cjs.development.js:1405:30 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.development.js:370:39 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.development.js:1201:44 in __generator$argument_1
at node_modules/@sentry/integrations/node_modules/tslib/tslib.js:141:21 in step
at node_modules/@sentry/integrations/node_modules/tslib/tslib.js:122:60 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.development.js:109:13 in Promise$argument_0
at node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.development.js:91:11 in __async
at node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.development.js:1153:30 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.development.js:1152:26 in <anonymous>
at node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.development.js:370:39 in <anonymous>
at src/providers/Urql.js:91:14 in Promise$argument_0
at src/providers/Urql.js:90:25 in useCallback$argument_0
at src/providers/Urql.js:85:40 in useCallback$argument_0
at src/providers/Urql.js:116:23 in useCallback$argument_0
at [native code]:null in callFunctionReturnFlushedQueue

On the onDisconnect event I believe currentConnection just needs to return to null. The try/catch approach in #20 would also work.


✅ I'm comfortable submitting a PR for this if needed

jk-gan commented 2 years ago

We just released version 2.0.0, this issue should be fixed.