- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2k
 
Description
Bug description
When a subscribed exception handler itself throws exceptions, the AbstractBedrockApi will infinitely try to complete the stream.
Environment
Spring AI 1.0.0-snapshot
openjdk 17.0.13 2024-10-15
Steps to reproduce
Create a Flux stream like so:
Anthropic3ChatBedrockApi api = new Anthropic3ChatBedrockApi(...); api.chatCompletionStream(request).subscribe(response -> { throw NullPointerException("some error1"); }, ex -> throw NullPointerException("some error2") ), () -> throw NullPointerException("some error3") );
Expected behavior
I'd expect an exception to be thrown.
Instead, I see
Emitting complete:FAIL_TERMINATED
output to console very rapidly and infinitely
This is because of the while loop in AbstractBedrockApi.internalInvocationStream() never meeting its exit condition.
If an errorHandler throws an exception persistently, this can take down a service depending on what else the error handler is doing, there should be a circuit breaker that terminates the Flux stream.