File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -250,8 +250,16 @@ internal static async Task OpenAsyncWithSqlErrorHandling(this SqlConnection conn
250250 /// <returns>True if the exception is a fatal SqlClientException, false otherwise</returns>
251251 internal static bool IsFatalSqlException ( this Exception e )
252252 {
253+ string lowerMessage = e . Message . ToLowerInvariant ( ) ;
253254 // Most SqlExceptions wrap the original error from the native driver, so make sure to check both
254- return ( e as SqlException ) ? . Class >= 20 || ( e . InnerException as SqlException ) ? . Class >= 20 ;
255+ return ( e as SqlException ) ? . Class >= 20
256+ || ( e . InnerException as SqlException ) ? . Class >= 20
257+ // TEMPORARY - Not all exceptions thrown by SqlClient are SqlExceptions, and the current SqlClient
258+ // does not correctly update the State property in all cases. So for now explicitly check for
259+ // the string containing a message indicating that the connection has been closed or broken.
260+ // This should be removed once version 5.2.0+ has been released
261+ // https://github.com/Azure/azure-functions-sql-extension/issues/860
262+ || ( lowerMessage . Contains ( "connection" ) && ( lowerMessage . Contains ( "broken" ) || lowerMessage . Contains ( "closed" ) ) ) ;
255263 }
256264
257265 /// <summary>
You can’t perform that action at this time.
0 commit comments