123123213weqw opened a new pull request, #5757: URL: https://github.com/apache/rocketmq-dashboard/pull/5757
## What\n\n`AiRunService.attach` creates the `AgentStreamSession` — whose constructor starts a 15 s heartbeat on the shared scheduler — before it queries the timeline. Nothing between that point and the return of the emitter is guarded: a failure in the replay read (a database exception from `findByConversationIdAfterSeq`, or anything thrown while decoding rows) propagated out of the controller, and the emitter it had created never reached a response.\n\n## Why it is a bug\n\nAn emitter that is never returned to Spring MVC never gets its `onCompletion`/`onTimeout`/`onError` callbacks, so nothing ever closes the session. Its heartbeat task then keeps firing every 15 s for the life of the process, sending into the emitter's internal early-send buffer that nobody drains — a slow leak of a scheduler task plus buffered frames per failed attach. The session also never entered the registry, so no run cleanup path can reach it either.\n\n## The fix\n\nWrap the replay query and decod e loop: on any `RuntimeException`, complete the session (idempotent, stops the heartbeat, clears the buffer) and rethrow so the caller still sees the failure. The happy path is unchanged.\n\n## Test\n\nRed-first: `AiRunServiceTest.aFailingReplayReadMustCloseTheSessionItCreatedTest` makes the timeline read throw and asserts the created emitter was completed before the exception surfaced. Fails on the previous code (session left open), passes with the guard; the class (23 tests) stays green. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
