From 7251b0f9f5ed5c6b27349d294f8fa6d2ca2cb067 Mon Sep 17 00:00:00 2001 From: Wil Wilsman Date: Mon, 15 Aug 2022 13:03:56 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Do=20not=20implicitly=20reset=20?= =?UTF-8?q?testing=20mode=20remote=20connections=20(#1034)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Having remote connections disconnect and reconnect between each test causes unnecessary load and can sometimes even cause SDK tests to hang. By avoiding this implicit disconnect we can avoid SDK test flakes/hangs. --- packages/core/src/api.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/api.js b/packages/core/src/api.js index 9ef7a79ce..37539fb47 100644 --- a/packages/core/src/api.js +++ b/packages/core/src/api.js @@ -118,12 +118,12 @@ export function createPercyServer(percy, port) { // manipulates testing mode configuration to trigger specific scenarios .route('/test/api/:cmd', ({ body, params: { cmd } }, res) => { body = Buffer.isBuffer(body) ? body.toString() : body; + let { remoteLoggers } = percy.testing; if (cmd === 'reset') { - // the reset command will terminate connections, clear logs, and reset testing mode - percy.testing.remoteLoggers?.forEach(ws => ws.terminate()); + // the reset command will reset testing mode and clear any logs + percy.testing = remoteLoggers ? { remoteLoggers } : {}; logger.instance.messages.clear(); - percy.testing = {}; } else if (cmd === 'version') { // the version command will update the api version header for testing percy.testing.version = body; @@ -135,7 +135,7 @@ export function createPercyServer(percy, port) { percy.testing.build = { failed: true, error: 'Build failed' }; } else if (cmd === 'remote-logging') { // the remote-logging command will toggle remote logging support - if (body === false) percy.testing.remoteLoggers?.forEach(ws => ws.terminate()); + if (body === false) remoteLoggers?.forEach(ws => ws.terminate()); percy.testing.remoteLogging = body; } else { // 404 for unknown commands