Bug #114257 Error Handling Issue with MySql.EntityFrameworkCore
Submitted: 7 Mar 2024 8:48 Modified: 8 Mar 2024 4:07
Reporter: WEI CHI WANG Email Updates:
Status: Analyzing Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:7.0.2 OS:Windows (11)
Assigned to: MySQL Verification Team CPU Architecture:x86 (i5-12500)

[7 Mar 2024 8:48] WEI CHI WANG
Description:
When attempting to execute asynchronous methods like CanConnectAsync(), ToListAsync(), etc., with MySQL.EntityFrameworkCore and encountering a blocked connection due to firewall restrictions or incorrect host entry, the application experiences uncatchable exceptions, leading to immediate application crashes. Synchronous methods, however, function correctly under the same circumstances.

How to repeat:
1. Set up MySql.EntityFrameworkCore in an application.
2. Intentionally block the connection using a firewall or provide incorrect host information.
3. Invoke asynchronous methods such as CanConnectAsync(), ToListAsync(), etc.
4. Observe the application crash without the ability to catch the exception.

Suggested fix:
The expected behavior should involve the proper handling of exceptions when the connection is blocked by a firewall or an incorrect host address is provided. Instead of crashing the application, it should gracefully handle the exception, allowing for proper error logging and application stability.
[7 Mar 2024 9:22] WEI CHI WANG
Occurred in ASP.NET Core MVC controller action
[7 Mar 2024 11:56] MySQL Verification Team
Hello!

Thank you for the bug report.
Could you please provide repeatable test case (sample project etc. - please make it as private if you prefer) to repeat this issue at our end?

Regards,
Ashwini Patil
[8 Mar 2024 1:22] WEI CHI WANG
Hello Ashwini Patil,

Thank you for your prompt response and for reviewing the bug report. I've provided the sample project and the code snippet where the uncaught exception occurs below:

Sample project: https://gitlab.com/wei-chi.wang/mysql.entityframeworkcore.bug.reappear

Code snippet where the uncaught exception occurs: https://gitlab.com/wei-chi.wang/mysql.entityframeworkcore.bug.reappear/-/blame/main/Contro...

Please let me know if you need any further information or assistance.

Best regards,
WEI CHI WANG