dio icon indicating copy to clipboard operation
dio copied to clipboard

flutter web console show Bad state: Future already completed

Open alreadytaken1990 opened this issue 2 years ago • 14 comments

New Issue Checklist

  • [x] I have searched for a similar issue in the project and found none

Issue Info

Info Value
Platform Name web
Platform Version -
Dio Version 4.0.5
Android Studio / Xcode Version - (vscode&pkged)
Repro rate all the time (100%)
Repro with our demo prj -
Demo project link -

Issue Description and Steps

show error in broswer console: Bad state: Future already completed 4.0.4 doesnt have this error

alreadytaken1990 avatar Mar 31 '22 02:03 alreadytaken1990

Similar issue here (4.0.5 and 4.0.6). when a connectimeout options is set. This error come at last connecttimeout. image

DevFauche avatar Mar 31 '22 07:03 DevFauche

I can confirm - I am facing the same issue in my Interceptor. Removing the timeout options resolves the issue, though this is not a permanent fix ...

FrankNanninga avatar Apr 10 '22 22:04 FrankNanninga

Same issue found~

figbin avatar Apr 13 '22 06:04 figbin

I am also getting same issue

Error: Bad state: Future already completed at Object.throw_ [as throw] (http://localhost:57202/dart_sdk.js:5067:11) at _AsyncCompleter.new.completeError (http://localhost:57202/dart_sdk.js:35195:51) at http://localhost:57202/packages/dio/src/interceptors/log.dart.lib.js:651:25 at _RootZone.runUnary (http://localhost:57202/dart_sdk.js:40441:59) at _FutureListener.then.handleValue (http://localhost:57202/dart_sdk.js:35363:29) at handleValueCallback (http://localhost:57202/dart_sdk.js:35931:49) at Function._propagateToListeners (http://localhost:57202/dart_sdk.js:35969:17) at _Future.new.[_complete] (http://localhost:57202/dart_sdk.js:35809:25) at http://localhost:57202/dart_sdk.js:34915:30 at internalCallback (http://localhost:57202/dart_sdk.js:26619:11)

viralkachhadiya avatar Apr 13 '22 06:04 viralkachhadiya

Can confirm as well. Downgrading to 4.0.4 or removing the timeout options resolves the issue.

RootSoft avatar Apr 15 '22 10:04 RootSoft

Could it be that this is the culprit:

... elided ...
request = await reqFuture;
if (options.connectTimeout > 0) {
  request = await reqFuture
      .timeout(Duration(milliseconds: options.connectTimeout));
} else {
  request = await reqFuture;
... elided ...

?

(See line 47).

It appears the call on line 47 is not needed since both conditions of the if do the call. Perhaps this is a duplicate?

augb avatar Apr 18 '22 21:04 augb

Same issue in my project. As mentioned by @RootSoft, downgrading to 4.0.4 fixed it.

#1470 fixes this issue

llfbandit avatar Apr 25 '22 17:04 llfbandit

昨晚发版,这个问题我一直没关注到是BrowserHttpClientAdapter的错误,排查了很久,五一第一天emo了,啊哈哈

SystemTce avatar May 01 '22 01:05 SystemTce

I have the same problem dio: ^4.0.6

andrew2558 avatar May 01 '22 10:05 andrew2558

I have the same problem dio: ^4.0.6

My problem was solved because I called super in onRequest

andrew2558 avatar May 02 '22 02:05 andrew2558

I can confirm - I am facing the same issue in my Interceptor. Removing the timeout options resolves the issue, though this is not a permanent fix ...

same

typenoob avatar May 04 '22 04:05 typenoob

Can confirm, too. Is in there since 4.0.5, 4.0.4 seems to be ok.

lukey78 avatar May 11 '22 19:05 lukey78

i seem to have the same issue on iOS and Android as well

karen1au avatar May 19 '22 15:05 karen1au