From 831f3051ea8d28a5cec9a7a96ca48099d79397ab Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 11 Feb 2026 17:07:33 +0800 Subject: [PATCH] Ensure SafeWriter is closed before reading buffer in test - Added a call to `CloseSafeWriter` in `TestJsValueStreamingWorkflow` to flush all pending async writes before reading the output buffer. This change improves test reliability, particularly on slow CI runners, by preventing potential issues with empty buffers. --- agent/context/jsapi_output_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/agent/context/jsapi_output_test.go b/agent/context/jsapi_output_test.go index b657addb..0f6397bf 100644 --- a/agent/context/jsapi_output_test.go +++ b/agent/context/jsapi_output_test.go @@ -1041,6 +1041,11 @@ func TestJsValueStreamingWorkflow(t *testing.T) { } assert.Equal(t, true, result["success"], "Streaming workflow should work correctly") + // Close SafeWriter to flush all pending async writes before reading buffer. + // SafeWriter processes writes in a background goroutine via channel; + // without this, the buffer may still be empty on slow CI runners. + cxt.CloseSafeWriter() + // Verify the complete workflow events output := mockWriter.buffer.String() assert.Contains(t, output, "message_start", "Output should contain message_start")