From efdb218edb7aae0c98d9ea06405f88787537f78c Mon Sep 17 00:00:00 2001 From: heqian <182359041@qq.com> Date: Thu, 15 Sep 2022 15:12:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20WEB=20=E7=AB=AFBUG=20error?= =?UTF-8?q?s.dart:266=20Uncaught=20(in=20promise)=20Error:=20Bad=20state:?= =?UTF-8?q?=20Future=20already=20completed=20=20=20=20=20at=20Object.throw?= =?UTF-8?q?=5F=20[as=20throw]=20(errors.dart:266:49)=20=20=20=20=20at=20?= =?UTF-8?q?=5FAsyncCompleter.new.completeError=20(future=5Fimpl.dart:15:79?= =?UTF-8?q?)=20=20=20=20=20at=20browser=5Fadapter.dart:70:22=20=20=20=20?= =?UTF-8?q?=20at=20=5FRootZone.runUnary=20(zone.dart:1653:54)=20=20=20=20?= =?UTF-8?q?=20at=20=5FFutureListener.then.handleValue=20(future=5Fimpl.dar?= =?UTF-8?q?t:147:18)=20=20=20=20=20at=20handleValueCallback=20(future=5Fim?= =?UTF-8?q?pl.dart:766:44)=20=20=20=20=20at=20=5FFuture.=5FpropagateToList?= =?UTF-8?q?eners=20(future=5Fimpl.dart:795:13)=20=20=20=20=20at=20[=5Fcomp?= =?UTF-8?q?lete]=20(future=5Fimpl.dart:557:7)=20=20=20=20=20at=20future.da?= =?UTF-8?q?rt:421:15=20=20=20=20=20at=20internalCallback=20(isolate=5Fhelp?= =?UTF-8?q?er.dart:48:19)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dio/lib/src/adapters/browser_adapter.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dio/lib/src/adapters/browser_adapter.dart b/dio/lib/src/adapters/browser_adapter.dart index 1dc1c1af2..7fba8f944 100644 --- a/dio/lib/src/adapters/browser_adapter.dart +++ b/dio/lib/src/adapters/browser_adapter.dart @@ -47,8 +47,9 @@ class BrowserHttpClientAdapter implements HttpClientAdapter { } var completer = Completer(); - + bool haveSent = false; xhr.onLoad.first.then((_) { + haveSent = true; Uint8List body = (xhr.response as ByteBuffer).asUint8List(); completer.complete( ResponseBody.fromBytes( @@ -61,8 +62,6 @@ class BrowserHttpClientAdapter implements HttpClientAdapter { ); }); - bool haveSent = false; - if (options.connectTimeout > 0) { Future.delayed(Duration(milliseconds: options.connectTimeout)).then( (value) {