From 65c6fd592c75c3cd64e4f7a09e1b98cb1796be43 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 7 May 2021 18:31:24 +0200 Subject: [PATCH] Log stderr instead of writing to test log During Travis integration tests a BrokenPipeError is emitted on stderr after the Factorio server has quit. I have no idea what's going on here so for now just log it and ignore it. --- test/integration/server.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/integration/server.js b/test/integration/server.js index e2796ea8..5d375e38 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -6,6 +6,7 @@ const path = require("path"); const libFactorio = require("@clusterio/lib/factorio"); const libErrors = require("@clusterio/lib/errors"); +const { logger } = require("@clusterio/lib/logging"); const { slowTest } = require("./index"); @@ -34,6 +35,15 @@ describe("Integration of lib/factorio/server", function() { await fs.ensureDir(writePath); logFile = fs.createWriteStream(path.join(writePath, "log.txt"), "utf8"); server.on("output", function(output) { + if (output.source === "stderr") { + // Factorio doesn't print on stderr but sometimes on + // Travis a BrokenPipeError is printed on stderr after + // the server has closed for mysterious reasons. + // I have no idea what causes it, but it causes a write + // after end error if not handled. + logger.error(`Factorio stderr: ${JSON.stringify(output)}`); + return; + } logFile.write(`${JSON.stringify(output)}\n`); });