flagsmith-flutter-client icon indicating copy to clipboard operation
flagsmith-flutter-client copied to clipboard

Flagsmith client noisy warning logs in debug mode

Open tomwyr opened this issue 1 year ago • 1 comments

The current implementation of FlagsmithClient attaches sendTimeout from FlagsmithConfig to every http request it sends. On the web platform, this causes dio client to log warnings about the timeout property being incorrectly set for GET requests:

[🔔 Dio] sendTimeout cannot be used without a request body to send
[🔔 Dio] _StackTrace (dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 843:28  get current
         dio_web_adapter-2.0.0/lib/src/adapter.dart 149:22                   fetch
         dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 84:54  runBody
         dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 127:5  _async
         dio_web_adapter-2.0.0/lib/src/adapter.dart 31:29                    fetch
         packages/dio/src/dio_mixin.dart 529:27                              _dispatchRequest
         dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50  <fn>
         ...
         )

Consider making FlagsmithClient ignore the timeout property from config for those requests, e.g. by overriding base options for calls with no body:

// flagsmith_client.dart

Options? get _apiGetOptions {
  if (kIsWeb) {
    return Options(sendTimeout: Duration.zero);
  }
  return null;
}

// ...

Future<List<Flag>> _getFlags() async {
    try {
      var response = await _api.get<List<dynamic>>(config.flagsURI, options: _apiGetOptions);
      // ...
}

tomwyr avatar Oct 23 '24 09:10 tomwyr

Thanks for this @tomwyr , if you're willing to submit a PR for this, we'd gratefully receive it!

matthewelwell avatar Oct 23 '24 09:10 matthewelwell

Hey, I'd like to work on this issue, can you assign it to me.

deepraj02 avatar Jul 05 '25 22:07 deepraj02

Hi @deepraj02 , I've assigned it to you. Please go ahead and work on it and we'll look out for a PR soon.

matthewelwell avatar Jul 07 '25 08:07 matthewelwell

Thanks, going with the above mentioned "overriding" strategy !

deepraj02 avatar Jul 07 '25 09:07 deepraj02

https://github.com/Flagsmith/flagsmith-flutter-client/pull/76

deepraj02 avatar Jul 07 '25 10:07 deepraj02