Skip to content

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

Open
@fearless23

Description

@fearless23

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions