Process.stdout.write doesn't go to console

My package uses process.stdout.write instead of console.log to avoid the implicit newlines, however RunKit just discards the text. Are you planning to fix this? Or is there a way to detect that my package is running under the RunKit environment so that I can call console.log instead?

Hi @rzuich,

Good question! We do indeed currently just report console logs, under the idea that stdout.write is an implementation detail of console.log, vs. an essential quality (for example, console.log in the browser doesn’t stdout either). Additionally, this allows us to do the structured logging since we’re not getting raw text, but the actual object, which allows us to serialize it. One additionally benefit is that it doesn’t lead to costly I/O and thus improves performance.

That being said, it of course deviates from “normal” node in this regard, which can lead to issues like you faced. Regarding checking for RunKit, you could see if the"RUNKIT_ENDPOINT_URL " is present in process.env. Alternatively, you could try “detecting” it with something like this:

const originalWrite = process.stdout.write;
let consoleLogPrintsToStdout = false;
process.stdout.write = () => consoleLogPrintsToStdout = true;
console.log("test");
process.stdout.write = originalWrite;
if (consoleLogPrintsToStdout) { console.log("not on RunKit!"); }
else console.log("on RunKit!");

Very helpful, thank you. The next release will resolve this.