NullReferenceException in task workflow
See original GitHub issueWe have some healthcheck code with task workflows and the sometimes crash with NullReferenceException in some FSharp.Core code. I could not find the root cause yet, but I assume something in the task workflow compilation went wrong.
2022-09-30T05:31:27.174067241Z [40m [32minfo [39m [22m [49m: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
2022-09-30T05:31:27.174100942Z Executed endpoint 'Health checks'
2022-09-30T05:31:27.174773144Z [41m [30mfail [39m [22m [49m: Giraffe.Middleware.GiraffeErrorHandlerMiddleware[0]
2022-09-30T05:31:27.174789344Z An unhandled exception has occurred while executing the request.
2022-09-30T05:31:27.174794745Z System.NullReferenceException: Object reference not set to an instance of an object.
2022-09-30T05:31:27.175450247Z at Microsoft.FSharp.Core.CompilerServices.ResumableCode.TryFinallyCompensateDynamic[TData](ResumableStateMachine`1& sm, ResumptionFunc`1 mf, FSharpOption`1 savedExn) in D:\a\_work\1\s\src\FSharp.Core\resumable.fs:line 300
2022-09-30T05:31:27.175911749Z at ServerCode.HealthChecks.clo@78-88.Invoke(ResumableStateMachine`1& sm)
2022-09-30T05:31:27.175928149Z at <StartupCode$FSharp-Core>.$Tasks.resumptionInfo@171.MoveNext(ResumableStateMachine`1& sm) in D:\a\_work\1\s\src\FSharp.Core\tasks.fs:line 193
2022-09-30T05:31:27.175934449Z --- End of stack trace from previous location ---
2022-09-30T05:31:27.176169450Z at Prometheus.CollectorRegistry.CollectAndSerializeAsync(IMetricsSerializer serializer, CancellationToken cancel)
2022-09-30T05:31:27.176662752Z at ServerCode.HealthChecks.response@21.MoveNext() in /home/gitlab-runner/builds/1-vFfjTk/0/a-team/eCarApp/src/eCarCloud/HealthChecks.fs:line 30
2022-09-30T05:31:27.176683052Z at Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckMiddleware.InvokeAsync(HttpContext httpContext)
2022-09-30T05:31:27.176878353Z at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
2022-09-30T05:31:27.176893753Z at Giraffe.Middleware.Invoke@63-1.MoveNext()
2022-09-30T05:31:27.177142354Z [40m [32minfo [39m [22m [49m: Microsoft.AspNetCore.Hosting.Diagnostics[2]
2022-09-30T05:31:27.177157854Z Request finished HTTP/1.1 GET http://m8m-portal-staging.azurewebsites.net/metrics - 0 - 500 55 application/json;+charset=utf-8 240.8405ms
2022-09-30T05:31:27.211749099Z [40m [32minfo [39m [22m [49m: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
2022-09-30T05:31:27.211778599Z Executed endpoint 'Health checks'
2022-09-30T05:31:27.212076800Z [41m [30mfail [39m [22m [49m: Giraffe.Middleware.GiraffeErrorHandlerMiddleware[0]
2022-09-30T05:31:27.212241301Z An unhandled exception has occurred while executing the request.
2022-09-30T05:31:27.212252901Z System.NullReferenceException: Object reference not set to an instance of an object.
2022-09-30T05:31:27.212644202Z at Microsoft.FSharp.Core.CompilerServices.ResumableCode.TryFinallyCompensateDynamic[TData](ResumableStateMachine`1& sm, ResumptionFunc`1 mf, FSharpOption`1 savedExn) in D:\a\_work\1\s\src\FSharp.Core\resumable.fs:line 300
2022-09-30T05:31:27.212885603Z at ServerCode.HealthChecks.clo@78-88.Invoke(ResumableStateMachine`1& sm)
2022-09-30T05:31:27.212900804Z at <StartupCode$FSharp-Core>.$Tasks.resumptionInfo@171.MoveNext(ResumableStateMachine`1& sm) in D:\a\_work\1\s\src\FSharp.Core\tasks.fs:line 193
2022-09-30T05:31:27.212906704Z --- End of stack trace from previous location ---
2022-09-30T05:31:27.213123204Z at Prometheus.CollectorRegistry.CollectAndSerializeAsync(IMetricsSerializer serializer, CancellationToken cancel)
2022-09-30T05:31:27.213318705Z at ServerCode.HealthChecks.response@21.MoveNext() in /home/gitlab-runner/builds/1-vFfjTk/0/a-team/eCarApp/src/eCarCloud/HealthChecks.fs:line 30
2022-09-30T05:31:27.213333305Z at Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckMiddleware.InvokeAsync(HttpContext httpContext)
2022-09-30T05:31:27.213525706Z at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
2022-09-30T05:31:27.213540906Z at Giraffe.Middleware.Invoke@63-1.MoveNext()
2022-09-30T05:31:27.219065529Z [40m [32minfo [39m [22m [49m: Microsoft.AspNetCore.Hosting.Diagnostics[2]
2022-09-30T05:31:27.219084529Z Request finished HTTP/1.1 GET http://m8m-portal-staging.azurewebsites.net/metrics - - - 500 55 application/json;+charset=utf-8 290.0342ms
I think the code looks absolutely normal
Issue Analytics
- State:
- Created a year ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
How can I fix the error: System.NullReferenceException
A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. A NullReferenceException exception ...
Read more >NullReferenceException When Clicking a Task in Workflow ...
In my case folder Package was accidentally deleted from SharePoint App project. As soon as I recovered the folder everything started to work ......
Read more >NullReferenceException when awaiting a task only in ...
I've debugged this and nothing is null. It's just the await that blows up. I've also re-read over async await and I should...
Read more >Workflow issue- Dereferencing of the NULL reference
The erro says "Dereferencing of the NULL reference". Is this because of calling the FM in a seperate task, as the workflow already...
Read more >null error" when opening the Tasks page in WorkplaceXT.
Received null error message when trying to launch a workflow and received "Unable to load the task page: null error" when opening the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
so I looked briefly at the code in resumptionInfo:
so there is indeed some explicit null handling.
Although there is a “raise” that rethrows an exception in that method, so the exception could be happening earlier