File tree Expand file tree Collapse file tree 4 files changed +66
-8
lines changed
DotNetWorker.Grpc/Handlers Expand file tree Collapse file tree 4 files changed +66
-8
lines changed Original file line number Diff line number Diff line change 44- My change description (#PR/#issue)
55-->
66
7- ### Microsoft.Azure.Functions.Worker.Sdk 1.18.1
7+ ### Microsoft.Azure.Functions.Worker.Sdk < version >
88
9- - Updated ` Microsoft.Azure.Functions.Worker.Sdk.Generators ` reference to 1.3.4 .
9+ - Changed exception handling in function invocation path to ensure fatal exceptions bubble up .
1010
11- ### Microsoft.Azure.Functions.Worker.Sdk.Generators 1.3.4
12-
13- - Changed ` FunctionExecutorGenerator ` to avoid generation of long ` if ` /` else ` chains for apps with a large number of functions.
14-
15- - Use full namespace for ` Task.FromResult ` in function metadata provider generator to avoid namespace conflict (#2681 )
11+ ### Microsoft.Azure.Functions.Worker.Sdk.Generators <version >
1612
1713- <entry >
Original file line number Diff line number Diff line change 1+ using System ;
2+
3+ namespace Microsoft . Azure . Functions . Worker . Core
4+ {
5+ internal static class ExceptionExtensions
6+ {
7+ public static bool IsFatal ( this Exception ? exception )
8+ {
9+ while ( exception is not null )
10+ {
11+ if ( exception
12+ is ( OutOfMemoryException and not InsufficientMemoryException )
13+ or AppDomainUnloadedException
14+ or BadImageFormatException
15+ or CannotUnloadAppDomainException
16+ or InvalidProgramException
17+ or AccessViolationException )
18+ {
19+ return true ;
20+ }
21+
22+ exception = exception . InnerException ;
23+ }
24+
25+ return false ;
26+ }
27+ }
28+ }
Original file line number Diff line number Diff line change 66using System . Threading ;
77using System . Threading . Tasks ;
88using Microsoft . Azure . Functions . Worker . Context . Features ;
9+ using Microsoft . Azure . Functions . Worker . Core ;
910using Microsoft . Azure . Functions . Worker . Grpc ;
1011using Microsoft . Azure . Functions . Worker . Grpc . Features ;
1112using Microsoft . Azure . Functions . Worker . Grpc . Messages ;
@@ -113,7 +114,7 @@ public async Task<InvocationResponse> InvokeAsync(InvocationRequest request)
113114
114115 response . Result . Status = StatusResult . Types . Status . Success ;
115116 }
116- catch ( Exception ex )
117+ catch ( Exception ex ) when ( ! ex . IsFatal ( ) )
117118 {
118119 response . Result . Exception = _workerOptions . EnableUserCodeException ? ex . ToUserRpcException ( ) : ex . ToRpcException ( ) ;
119120 response . Result . Status = StatusResult . Types . Status . Failure ;
Original file line number Diff line number Diff line change 1+ using System ;
2+ using Microsoft . Azure . Functions . Worker . Core ;
3+ using Xunit ;
4+
5+ namespace Microsoft . Azure . Functions . Worker . Tests
6+ {
7+ public class ExceptionExtensionTests
8+ {
9+ [ Theory ]
10+ [ ClassData ( typeof ( ExceptionTestData ) ) ]
11+ public void IsFatal_ReturnsTrueForFatalExceptions ( Exception exception , bool isFatal )
12+ {
13+ var result = exception . IsFatal ( ) ;
14+
15+ Assert . Equal ( result , isFatal ) ;
16+ }
17+
18+ public class ExceptionTestData : TheoryData < Exception , bool >
19+ {
20+ public ExceptionTestData ( )
21+ {
22+ Add ( new OutOfMemoryException ( ) , true ) ;
23+ Add ( new AppDomainUnloadedException ( ) , true ) ;
24+ Add ( new BadImageFormatException ( ) , true ) ;
25+ Add ( new CannotUnloadAppDomainException ( ) , true ) ;
26+ Add ( new InvalidProgramException ( ) , true ) ;
27+ Add ( new AccessViolationException ( ) , true ) ;
28+ Add ( new InsufficientMemoryException ( ) , false ) ;
29+ Add ( new Exception ( "test" , new OutOfMemoryException ( ) ) , true ) ;
30+ }
31+ }
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments