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

Bad State: Future already completed (dio package ) #230

Open
fearless23 opened this issue May 31, 2022 · 0 comments
Open

Bad State: Future already completed (dio package ) #230

fearless23 opened this issue May 31, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@fearless23
Copy link

I am using example from https://github.com/GetStream/stream-feed-flutter/tree/master/example

Getting following error twice

Error: Bad state: Future already completed
    at Object.throw_ [as throw] (http://localhost:57032/dart_sdk.js:5080:11)
    at _AsyncCompleter.new.completeError (http://localhost:57032/dart_sdk.js:35274:51)
at http://localhost:57032/packages/dio/src/interceptors/log.dart.lib.js:651:25
    at _RootZone.runUnary (http://localhost:57032/dart_sdk.js:40511:59)
    at _FutureListener.then.handleValue (http://localhost:57032/dart_sdk.js:35438:29)
    at handleValueCallback (http://localhost:57032/dart_sdk.js:35999:49)
    at _Future._propagateToListeners (http://localhost:57032/dart_sdk.js:36037:17)
    at [_complete] (http://localhost:57032/dart_sdk.js:35864:25)
    at http://localhost:57032/dart_sdk.js:34994:30
    at internalCallback (http://localhost:57032/dart_sdk.js:26685:11)

Everything works as expected on iOS and Android, but on web the wheel is spinning
On Debugging, the debugger stops at browser_adapter.dart which is a dio package file

if (options.connectTimeout > 0) {
      // this is the code which throws the error
      Future.delayed(Duration(milliseconds: options.connectTimeout)).then(
        (value) {
          if (!haveSent) {
            completer.completeError(
              DioError(
                requestOptions: options,
                error: 'Connecting timed out [${options.connectTimeout}ms]',
                type: DioErrorType.connectTimeout,
              ),
              StackTrace.current,
            );
            xhr.abort();
          }
        },
      );
    }

Tried following

From

final client = StreamFeedClient(apiKey,  appId: 'xxxxxxx' );
// default timeout = 10 seconds

to

final client = StreamFeedClient(
      apiKey,
      appId: 'xxxxxxx',
      options: const StreamHttpClientOptions(
        connectTimeout: Duration(seconds: 30),
      ),
    );

But the issue persists

@fearless23 fearless23 added the bug Something isn't working label May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant