-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
NEST/Elasticsearch.Net version:
7.17.5
Elasticsearch version:
Irrelevant (happens in unit tests as well)
.NET runtime version:
9
Operating system version:
Win11
Description of the problem including expected versus actual behavior:
A clear and concise description of what the bug is.
In case an exception arrives while running a BulkAll, although the exception is propegated towards the observable's on error, the interal implementatio of nest's ForEachAsync also throws the exception (after calling the "done" method).
As such, an unobserved exception will trigger even if the actual exception is touched by OnException overload.
Steps to reproduce:
- Create a dummy in-memory response which returns a >500 error code.
- Call BulkAll
- Subscribe on said bulk all observable, use the exception
- Add a fictive long delay to allow GC to run, notice unobserved
Expected behavior
A clear and concise description of what you expected to happen.
No unobserved excpetion when actual exception is being treated.
Provide ConnectionSettings
(if relevant):
Provide DebugInformation
(if relevant):
Sample code:
var tsc = new TaskCompletionSource<bool>(ct, TaskCreationOptions.RunContinuationsAsynchronously);
var bulkAllObservable = Client.BulkAll(data, b => b.Index(indexName), ct);
using (bulkAllObservable.Subscribe(
_ => { },
exp =>
{
tsc.SetException(exp);
},
() => { tsc.SetResult(true); }))
{
await tsc.Task;
}
Suspected code issue:
catch (Exception obj)
{
done(obj);
throw;
}
In ForEachAsync method, notice that the actual throw is never catched in any flow (latest vesrions as well).