-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catching SocketException #38
Comments
Good day/night. Can you provide some code? |
Here the catch block never called Future<Record<T>> first<T>(
String query, {
required T Function(Map<String, String?> dbResult) toModel,
Map<String, dynamic>? params,
}) async {
try {
final result = await pool.execute(query, params);
final value = result.rows.firstOrNull;
if (value == null) {
return Record.notExist();
}
return Record(toModel(value.assoc()));
} catch (e, s) {
logger.e('mysql: select first operation failed', e, s);
return Record.error(msg: e.toString(), error: e);
}
} I tried to run await runZonedGuarded(
() => initServer(args),
(error, stack) {
logger.e('runZonedGuarded: ${error.toString()}', error, stack);
},
); Its kind wired, in the log I see two SocketException thrown! |
I think error is happening somewhere outside of your try catch block. Hard to tell right now |
No, I tested a lot. the error coming from mysql and the address of mysql server will be printed in the exception just to reproduce same error:
if try to add timeout to the request, when your WiFi is off, it will timeout then throw SocketException |
I mean because of asynchronous nature of this library, exception is thrown outside execute method. I need more time to test this behaviour |
I mean every request is multistep process, where request is send, and then asynchronously response is received. |
Thank you for the time you put on checking this issue. I found there is some bug in HttpClient on handling SocketException. According to this comment. You need to handle exception in onError callback. Maybe it help |
Yes. I think this is the only way to handle such async errors. Library should be refactored a little to accept onError callback |
Anyway this is something that can not be fixed in five minutes, so please if you can make some workaround temporary, provide your current solution here |
Hi. Thanks for your library.
Sometime I got SocketException and even if its wrapped in try catch the error will be thrown and can not be handled, this makes not able to return any response correctly. please could you fix it, any workaround?
SocketException: Operation timed out (OS Error: Operation timed out, errno = 60), address = ...
The text was updated successfully, but these errors were encountered: