enter image description here
I utilize SseEmitter for continuous data streaming to the client. The data comprises three categories: the initial n – 2 entries consist of regular JSON data, which is directly sent through ‘send’; the penultimate JSON entry can match the constant ‘DONE_DATA’, triggering the ‘complete’ method; the final entry is ‘[DONE]’, leading to an exception being thrown at the ‘extractChoices’ function due to formatting issues.
There are now two scenarios:
In the first scenario, the preceding n – 2 messages are transmitted seamlessly. However, the n – 1 data entry, for some unspecified reason, fails to align with the constant DONE_DATA, thereby impeding its completion. The nth data entry is ‘[DONE]’. At the stage of the extractChoices method, an exception is raised due to formatting difficulties preventing the conversion to JSON, subsequently triggering the onFailure method, and ultimately captured by a global exception handler.
In the second scenario, the initial n – 2 messages are sent successfully. The n – 1 data entry matches the DONE_DATA constant, triggering the completion process. The nth entry is ‘[DONE]’. An exception is thrown at the ‘extractChoices’ function due to formatting issues, leading to the execution of the onFailure method. However, in this case, the exception cannot be caught by the global handler but rather needs to be manually thrown at the onEvent location.
My inquiry pertains to the occurrence of the second scenario and the corresponding resolution strategies.
user24983241 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.