Skip to content

Commit

Permalink
🐛 Do not implicitly reset testing mode remote connections (#1034)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wwilsman authored Aug 15, 2022
1 parent 3332a2a commit 7251b0f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 7251b0f

Please sign in to comment.