From 447bb208111f8f881f4b3a5d985f1a3c010b02d2 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Wed, 12 Apr 2023 17:08:21 +0300 Subject: [PATCH] device-logs: Fix streaming suppressed logs warnings out of order Change-type: patch Connects-to: https://github.com/balena-io/open-balena-api/issues/1305 See: https://balena.zulipchat.com/#narrow/stream/346007-balena-io.2FbalenaCloud/topic/Random.20missing.20logs --- src/features/device-logs/lib/read.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/features/device-logs/lib/read.ts b/src/features/device-logs/lib/read.ts index 50cac73a1..371961d1a 100644 --- a/src/features/device-logs/lib/read.ts +++ b/src/features/device-logs/lib/read.ts @@ -95,7 +95,12 @@ async function handleStreamingRead( if (state === StreamState.Closed) { return; } - state = StreamState.Writable; + // Do not switch to Writable, unless we are in a Saturated state. + // Eg: We shouldn't if we are still Buffering waiting for getHistory to finish. + // This way warnings will go to the buffer if we are stil Buffering. + if (state === StreamState.Saturated) { + state = StreamState.Writable; + } if (dropped) { const now = Date.now(); onLog({