stream-feed-flutter icon indicating copy to clipboard operation
stream-feed-flutter copied to clipboard

Bad State: Future already completed (dio package )

Open fearless23 opened this issue 3 years ago • 0 comments

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 avatar May 31 '22 17:05 fearless23