From 06cdaddd714b3310574dcacabc6e416d03646b33 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Wed, 16 Jan 2019 13:14:49 +0000 Subject: [PATCH] Send connection message when streaming local mode logs Change-type: patch Signed-off-by: Cameron Diver --- src/device-api/v2.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/device-api/v2.ts b/src/device-api/v2.ts index bbe6762e..632bbc2e 100644 --- a/src/device-api/v2.ts +++ b/src/device-api/v2.ts @@ -327,6 +327,13 @@ export function createV2Api(router: Router, applications: ApplicationManager) { // Get the stream, and stream it into res const listenStream = backend.attachListener(); + // The http connection doesn't correctly intialise until some data is sent, + // which means any callers waiting on the data being returned will hang + // until the first logs comes through. To avoid this we send an initial + // message + res.write( + `${JSON.stringify({ message: 'Streaming logs', isSystem: true })}\n`, + ); listenStream.pipe(res); });