Description
Elastic.Clients.Elasticsearch version: 8.14.5
Elasticsearch version: 8.7.1
.NET runtime version: .NET 6
Operating system version: Windows 11
Description of the problem including expected versus actual behavior:
Calling multiple times SearchAsync and awaiting the responses after results in "Object reference not set to an instance of an object."
Steps to reproduce:
- Initialize a SearchRequest
- Call multiple times SearchAsync with the same SearchRequest and do NOT await the response, get the tasks instead
- Await the tasks execution after
Expected behavior
The tasks should be awaited correctly, returning the results of the searches.
Provide DebugInformation
(if relevant):
This wasn't an issue with NEST and ES7, it was reproduced after trying to upgrade to Elastic.Clients.Elasticsearch and ES8.
It was reproduced initially by running some tests that worked before the updates, that called some SearchAsync and CountAsync consecutively. The exception was sometimes thrown by the CountAsync too, so it's not limited to the SearchAsync method.
The next screenshot is a minimal test that reproduces the behaviour reported. The exception is thrown at the second or third awaited task.