Frezyx / talker

☎️ Advanced error handler and logger for dart and flutter apps
https://pub.dev/packages/talker
MIT License
478 stars 57 forks source link

Error "object is unsendable" when using TalkDioLogger inside isolate #219

Open berbsd opened 4 months ago

berbsd commented 4 months ago

I am curious if anyone has seen this problem before. I don't have a small code sample to repro at this time, but can put one together if really needed.

I am using a shared instance of Dio between my main thread and different isolates. It works well, unless I use the TalkerDioLogger with the main talker instance declared in my main function. In this case, the error below happens constantly. If I remove talker, then everything works flawlessly. It is 100% repeatable for me (and annoying).

I tried different ways to implement my isolates but to no avail. if I add interceptor to the shared client within the isolate with a separate instance of talker, then no issues, but logs are not visible at all.

Any pointers would be greatly appreciated.

Thx

David

     │ [error] | 0:18:26 673ms | Invalid argument(s): Illegal argument in isolate message: object is unsendable - Library:'dart:async' Class: _AsyncCompleter@4048458 (see restrictions listed at `SendPort.send()` documentation for more information)
     │  <- controller in Instance of 'MapUpdated' (from package:mobile_app/views/charger_search/bloc/charger_search_bloc.dart)
     │  <- Instance of 'Transition<ChargerSearchEvent, ChargerSearchState>' (from package:bloc/src/transition.dart)
     │  <- Instance of 'BlocStateLog' (from package:talker_bloc_logger/bloc_logs.dart)
     │  <- _List len:63 (from dart:core)
     │  <- Instance(length:44) of '_GrowableList' (from dart:core)
     │  <- _history in Instance of 'DefaultTalkerHistory' (from package:talker/src/history.dart)
     │  <- _history in Instance of 'Talker' (from package:talker/src/talker.dart)
     │  <- _talker in Instance of 'TalkerDioLogger' (from package:talker_dio_logger/talker_dio_logger_interceptor.dart)
     │  <- _List len:3 (from dart:core)
     │  <- Instance(length:3) of '_GrowableList' (from dart:core)
     │  <- Instance of 'Interceptors' (from package:dio/src/dio_mixin.dart)
     │  <- Instance of 'DioForNative' (from package:dio/src/dio/dio_for_native.dart)
     │  <- Record (0, Instance of 'DioForNative', Instance(length:1) of '_GrowableList', Instance of 'RootIsolateToken') (from dart:core)
     │