I have the exact same issue as the person in this locked thread: Nest 6.6 getting InvalidProgramException sometimes
The only difference is that I am using NEST 6.3.1 with .NET Core 3.1. That post is closed after last mentioning a ticket that I am not able to follow up on, so I am making another to track this. This issue has just recently started having an impact for my microservice which is deployed in the cloud using kubernetes. We also have Elastic APM enabled. The first time I've experienced this is yesterday, so I am in the process of figuring out what may have changed, but the error seems to come from the NEST client. Here is the stack trace:
at Elasticsearch.Net.Transport`1.RequestAsync[TResponse](HttpMethod method, String path, CancellationToken cancellationToken, PostData data, IRequestParameters requestParameters)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Elasticsearch.Net.Transport`1.RequestAsync[TResponse](HttpMethod method, String path, CancellationToken cancellationToken, PostData data, IRequestParameters requestParameters)
at Elasticsearch.Net.ElasticLowLevelClient.DoRequestAsync[TResponse](HttpMethod method, String path, CancellationToken cancellationToken, PostData data, IRequestParameters requestParameters)
at Elasticsearch.Net.ElasticLowLevelClient.CountAsync[TResponse](String index, String type, PostData body, CountRequestParameters requestParameters, CancellationToken ctx)
at Nest.LowLevelDispatch.CountDispatchAsync[TResponse](IRequest`1 p, SerializableData`1 body, CancellationToken ct)
at Nest.ElasticClient.Nest.IHighLevelToLowLevelDispatcher.DispatchAsync[TRequest,TQueryString,TResponse,TResponseInterface](TRequest request, CancellationToken cancellationToken, Func`3 responseGenerator, Func`4 dispatch)