Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flagsmith client noisy warning logs in debug mode #67

Open
tomwyr opened this issue Oct 23, 2024 · 1 comment
Open

Flagsmith client noisy warning logs in debug mode #67

tomwyr opened this issue Oct 23, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@tomwyr
Copy link

tomwyr commented Oct 23, 2024

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);
      // ...
}
@matthewelwell
Copy link
Contributor

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

@matthewelwell matthewelwell added enhancement New feature or request good first issue Good for newcomers labels Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants