MichaelMarner / dart-redux-remote-devtools

Remote Devtools for Dart & Flutter
https://pub.dartlang.org/packages/redux_remote_devtools
MIT License
52 stars 10 forks source link

connect to dev tools hangs #23

Open imod opened 4 years ago

imod commented 4 years ago

My environment setup is:

I use the following code to setup my store:

import 'dart:developer';

import 'package:mplan/epics/weekplan_epics.dart';
import 'package:mplan/login/auth_epics.dart';
import 'package:mplan/model/app_state.dart';
import 'package:mplan/reducers/app_reducer.dart';
import 'package:redux/redux.dart';
import 'package:redux_dev_tools/redux_dev_tools.dart';
import 'package:redux_epics/redux_epics.dart';
import 'package:redux_logging/redux_logging.dart';
import 'package:redux_remote_devtools/redux_remote_devtools.dart';

Future<Store<AppState>> setupStore() async {
  log('setup');
  // TOOD add switch to disable devtools for production build
  final remoteDevtools = RemoteDevToolsMiddleware('192.168.1.106:8000');
  final epic = combineEpics<AppState>([
    loginEpic,
    logoutEpic,
    defaultGroupEpic,
    loadDayPlansEpic,
  ]);
  final epicMiddleware = EpicMiddleware(epic);
  // final store = Store<AppState>(
  final store = DevToolsStore<AppState>(
    appReducer,
    initialState: AppState(),
    middleware: [
      // LoggingMiddleware.printer(),
      epicMiddleware,
      remoteDevtools,
    ],
  );

  remoteDevtools.store = store;
  log('before connect');
  await remoteDevtools.connect();
  log('after connect');

  return store;
}

I start the server with:

remotedev --port 8000

when starting the app on the iOS simulator I only get the following output (please note the log(...)-call in the store setup code):

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Xcode build done.                                           30.6s
    path: satisfied (Path is satisfied), interface: en0
Configuring the default Firebase app...
    path: satisfied (Path is satisfied), interface: en0
Configured the default Firebase app __FIRAPP_DEFAULT.
[log] setup
[log] before connect

after a couple of minutes, the following output also comes along:

    [C1.1 E305D8AA-0FCD-4691-92D7-553C1EA8E75C 2a02:120b:c3ee:9890:80f6:5fac:e4ad:a5b8.50478<->2a00:1450:400a:800::200a.443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 239.973s, DNS @0.002s took 0.002s, TCP @0.006s took 0.015s, TLS took 0.043s
    bytes in/out: 4487/1485, packets in/out: 8/10, rtt: 0.013s, retransmitted packets: 0, out-of-order packets: 0

so there is no after connect and screen in the iOS simulator will just stay white. The IP in the code is correct, but I also get the same behaviour when I use localhost:8000 Is there any way I can debug this in more details?

when I remove the remote dev tools and just use the alternative LoggingMiddleware.printer(), everything works fine.

denis-isaev commented 4 years ago

I have experienced similar problems. This scenario works for me: 1) run app without await: remoteDevtools.connect(); 2) add await: await remoteDevtools.connect(); and do hot reload

And don't forget about firewall.

chougron commented 3 years ago

I had the same issue, and did the following :

await (remoteDevTools.connect() as Future).timeout(Duration(seconds: 10));

Sometimes when launching the application it will not connect, and if I hot reload after that, it will be ok.

MichaelMarner commented 3 years ago

Hey everyone, quick question:

Does your app hang on the white screen if you already have the remote devtools open in a web browser (ie you have localhost:8000 open in chrome)?

I'm trying to get to the bottom of this, and I think what I am seeing is remotedev-server not accepting packets unless you have the browser tab open.

One workaround for this is to do what @denis-isaev does, and not await the connect call. Indeed, in apps that I work on, we don't await connect.

Just trying to better understand the issue.

Cheers