"Common Language Runtime detected an invalid program." using NEST

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)

How can I reply to the original topic? It's kind of absurd that I can't reach out to the people with knowledge of my exact same problem just last month.

bump to prevent closure

@Martijn_Laarman do you know?

1 Like

@nestrq can I bother you once more to open this as an issue on: https://github.com/elastic/elasticsearch-net. Would be the best place to coordinate this further.

Thank you for your persistence in keeping this alive and @dadoonet for pulling me in.

It would also help us if you are able to update to the latest version of the client to know if the problem persists.

1 Like

@Martijn_Laarman thanks for your reply! I can certainly do that.

About upgrading the client, I thought the client we used was supposed to tie into the version of ES we are on - is that not the case? I can't update to 7.xx as we are on ES 6.xx.

I can't update to 7.xx as we are on ES 6.xx.

This is very true! I should have been more explicit and mentioned upgrading to the latest 6.x minor: