Skip to content

Commit 83a1a3d

Browse files
committed
fix: better error messages on worker message timeouts
1 parent 6c68043 commit 83a1a3d

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

lib/src/frame_cryptor_impl.dart

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ class KeyProviderImpl implements KeyProvider {
148148
logger.fine('waiting for init on msg: $msgId');
149149
return event.msgId == msgId;
150150
},
151-
duration: Duration(seconds: 15),
151+
duration: Duration(seconds: 5),
152+
onTimeout: () => throw Exception('waiting for init on msg timed out'),
152153
);
153154
}
154155

@@ -168,7 +169,8 @@ class KeyProviderImpl implements KeyProvider {
168169
logger.fine('waiting for dispose on msg: $msgId');
169170
return event.msgId == msgId;
170171
},
171-
duration: Duration(seconds: 15),
172+
duration: Duration(seconds: 5),
173+
onTimeout: () => throw Exception('waiting for dispose on msg timed out'),
172174
);
173175

174176
_keys.clear();
@@ -197,7 +199,8 @@ class KeyProviderImpl implements KeyProvider {
197199
logger.fine('waiting for setKey on msg: $msgId');
198200
return event.msgId == msgId;
199201
},
200-
duration: Duration(minutes: 15),
202+
duration: Duration(seconds: 5),
203+
onTimeout: () => throw Exception('waiting for setKey on msg timed out'),
201204
);
202205

203206
_keys[participantId] ??= [];
@@ -230,7 +233,9 @@ class KeyProviderImpl implements KeyProvider {
230233
logger.fine('waiting for ratchetKey on msg: $msgId');
231234
return event.msgId == msgId;
232235
},
233-
duration: Duration(seconds: 15),
236+
duration: Duration(seconds: 5),
237+
onTimeout: () =>
238+
throw Exception('waiting for ratchetKey on msg timed out'),
234239
);
235240

236241
return base64Decode(res.data['newKey']);
@@ -257,7 +262,9 @@ class KeyProviderImpl implements KeyProvider {
257262
logger.fine('waiting for exportKey on msg: $msgId');
258263
return event.msgId == msgId;
259264
},
260-
duration: Duration(seconds: 15),
265+
duration: Duration(seconds: 5),
266+
onTimeout: () =>
267+
throw Exception('waiting for exportKey on msg timed out'),
261268
);
262269

263270
return base64Decode(res.data['exportedKey']);
@@ -280,7 +287,9 @@ class KeyProviderImpl implements KeyProvider {
280287
logger.fine('waiting for exportSharedKey on msg: $msgId');
281288
return event.msgId == msgId;
282289
},
283-
duration: Duration(seconds: 15),
290+
duration: Duration(seconds: 5),
291+
onTimeout: () =>
292+
throw Exception('waiting for exportSharedKey on msg timed out'),
284293
);
285294

286295
return base64Decode(res.data['exportedKey']);
@@ -302,7 +311,9 @@ class KeyProviderImpl implements KeyProvider {
302311
logger.fine('waiting for ratchetSharedKey on msg: $msgId');
303312
return event.msgId == msgId;
304313
},
305-
duration: Duration(seconds: 15),
314+
duration: Duration(seconds: 5),
315+
onTimeout: () =>
316+
throw Exception('waiting for ratchetSharedKey on msg timed out'),
306317
);
307318

308319
return base64Decode(res.data['newKey']);
@@ -326,7 +337,9 @@ class KeyProviderImpl implements KeyProvider {
326337
logger.fine('waiting for setSharedKey on msg: $msgId');
327338
return event.msgId == msgId;
328339
},
329-
duration: Duration(seconds: 15),
340+
duration: Duration(seconds: 5),
341+
onTimeout: () =>
342+
throw Exception('waiting for setSharedKey on msg timed out'),
330343
);
331344
}
332345

@@ -347,7 +360,9 @@ class KeyProviderImpl implements KeyProvider {
347360
logger.fine('waiting for setSifTrailer on msg: $msgId');
348361
return event.msgId == msgId;
349362
},
350-
duration: Duration(seconds: 15),
363+
duration: Duration(seconds: 5),
364+
onTimeout: () =>
365+
throw Exception('waiting for setSifTrailer on msg timed out'),
351366
);
352367
}
353368
}

0 commit comments

Comments
 (0)