aws-xray-sdk-dotnet: DefaultExceptionSerializationStrategy Throw System.NullReferenceException

Occasionally throw exceptions: AWSXRayRecorder.Handlers.AspNetCore : 2.6.0

Microsoft.AspNetCore.Server.Kestrel ERROR 58  Connection id "0HLOVUBU82R61", Request id "0HLOVUBU82R61:00000048": An unhandled exception was thrown by the application. 
System.NullReferenceException: Object reference not set to an instance of an object.
   at Amazon.XRay.Recorder.Core.Strategies.DefaultExceptionSerializationStrategy.<>c__DisplayClass14_0.<DescribeException>b__3(ExceptionDescriptor d)
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at Amazon.XRay.Recorder.Core.Strategies.DefaultExceptionSerializationStrategy.DescribeException(Exception e, IEnumerable`1 subsegments)
   at Amazon.XRay.Recorder.Core.Internal.Entities.Entity.AddException(Exception e)
   at Amazon.XRay.Recorder.Core.AWSXRayRecorderImpl.AddException(Exception ex)
   at Amazon.XRay.Recorder.Handlers.AspNetCore.Internal.AWSXRayMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Sporadically get similar exception in AWS Lambda:

{
            "Depth": 0,
            "ClassName": "System.NullReferenceException",
            "Message": "Object reference not set to an instance of an object.",
            "Source": "AWSXRayRecorder.Core",
            "StackTrace": [
                "   at Amazon.XRay.Recorder.Core.Strategies.DefaultExceptionSerializationStrategy.<>c__DisplayClass14_0.<DescribeException>b__3(ExceptionDescriptor d)",
                "   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)",
                "   at Amazon.XRay.Recorder.Core.Strategies.DefaultExceptionSerializationStrategy.DescribeException(Exception e, IEnumerable`1 subsegments)",
                "   at Amazon.XRay.Recorder.Core.Internal.Entities.Entity.AddException(Exception e)",
                "   at Amazon.XRay.Recorder.Core.AWSXRayRecorderImpl.AddException(Exception ex)",
                "   at OS33.Serverless.Core.AwsLambda`2.LambdaHandler(TData data, ILambdaContext context)"
            ],
            "HResult": -2147467261,
            "HelpURL": null
        }

Lambda is called by Cloufwatch Event by timer every five minutes. Can you help fix this bug? Any workarounds?