@@ -34,13 +34,15 @@ class ClientIO extends ClientBase with ClientMixin {
34
34
@override
35
35
late Map<String , String > config;
36
36
bool selfSigned;
37
+ bool _initProgress = false;
37
38
bool _initialized = false;
38
39
String? _endPointRealtime;
39
40
late http.Client _httpClient;
40
41
late HttpClient _nativeClient;
41
42
late CookieJar _cookieJar;
42
43
final List<Interceptor > _interceptors = [];
43
44
45
+ bool get initProgress => _initProgress;
44
46
bool get initialized => _initialized;
45
47
CookieJar get cookieJar => _cookieJar;
46
48
@override
@@ -126,6 +128,8 @@ class ClientIO extends ClientBase with ClientMixin {
126
128
}
127
129
128
130
Future init() async {
131
+ if(_initProgress) return;
132
+ _initProgress = true;
129
133
// if web skip cookie implementation and origin header as those are automatically handled by browsers
130
134
final Directory cookieDir = await _getCookiePath();
131
135
_cookieJar = PersistCookieJar(storage: FileStorage(cookieDir.path));
@@ -168,6 +172,7 @@ class ClientIO extends ClientBase with ClientMixin {
168
172
'user-agent', '${packageInfo.packageName}/${packageInfo.version} $device');
169
173
170
174
_initialized = true;
175
+ _initProgress = false;
171
176
}
172
177
173
178
Future<http .BaseRequest > _interceptRequest(http.BaseRequest request) async {
@@ -326,6 +331,9 @@ class ClientIO extends ClientBase with ClientMixin {
326
331
Map<String , dynamic > params = const {},
327
332
ResponseType? responseType,
328
333
}) async {
334
+ while (!_initialized && _initProgress) {
335
+ await Future.delayed(Duration(milliseconds: 10));
336
+ }
329
337
if (!_initialized) {
330
338
await init();
331
339
}
0 commit comments