fix: Display errors from isolates in the logs
This commit is contained in:
parent
0a9f8497e2
commit
9012ce6b2c
|
|
@ -217,7 +217,9 @@ class SSSS {
|
||||||
_KeyFromPassphraseArgs(
|
_KeyFromPassphraseArgs(
|
||||||
passphrase: passphrase,
|
passphrase: passphrase,
|
||||||
info: content.passphrase,
|
info: content.passphrase,
|
||||||
));
|
),
|
||||||
|
timeout: Duration(seconds: 10),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
// we need to just generate a new key from scratch
|
// we need to just generate a new key from scratch
|
||||||
privateKey = Uint8List.fromList(SecureRandom(SSSS_KEY_LENGTH).bytes);
|
privateKey = Uint8List.fromList(SecureRandom(SSSS_KEY_LENGTH).bytes);
|
||||||
|
|
@ -652,7 +654,9 @@ class OpenSSSS {
|
||||||
_KeyFromPassphraseArgs(
|
_KeyFromPassphraseArgs(
|
||||||
passphrase: passphrase,
|
passphrase: passphrase,
|
||||||
info: keyData.passphrase,
|
info: keyData.passphrase,
|
||||||
));
|
),
|
||||||
|
timeout: Duration(seconds: 10),
|
||||||
|
);
|
||||||
} else if (recoveryKey != null) {
|
} else if (recoveryKey != null) {
|
||||||
privateKey = SSSS.decodeRecoveryKey(recoveryKey);
|
privateKey = SSSS.decodeRecoveryKey(recoveryKey);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,16 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
import 'package:isolate/isolate.dart';
|
import 'package:isolate/isolate.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
Future<T> runInBackground<T, U>(
|
Future<T> runInBackground<T, U>(
|
||||||
FutureOr<T> Function(U arg) function, U arg) async {
|
FutureOr<T> Function(U arg) function,
|
||||||
|
U arg, {
|
||||||
|
Duration timeout,
|
||||||
|
dynamic Function() onTimeout,
|
||||||
|
}) async {
|
||||||
IsolateRunner isolate;
|
IsolateRunner isolate;
|
||||||
try {
|
try {
|
||||||
isolate = await IsolateRunner.spawn();
|
isolate = await IsolateRunner.spawn();
|
||||||
|
|
@ -28,9 +33,17 @@ Future<T> runInBackground<T, U>(
|
||||||
// web does not support isolates (yet), so we fall back to calling the method directly
|
// web does not support isolates (yet), so we fall back to calling the method directly
|
||||||
return await function(arg);
|
return await function(arg);
|
||||||
}
|
}
|
||||||
|
final sub = isolate.errors
|
||||||
|
.listen((error) => Logs().e('Error caught in isolate', error));
|
||||||
try {
|
try {
|
||||||
return await isolate.run(function, arg);
|
return await isolate.run(
|
||||||
|
function,
|
||||||
|
arg,
|
||||||
|
timeout: timeout,
|
||||||
|
onTimeout: onTimeout,
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
await sub.cancel();
|
||||||
await isolate.close();
|
await isolate.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue