maxmcd / webtty

Share a terminal session over WebRTC

Home Page:https://maxmcd.github.io/webtty/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure pipelines truncates connection data

davej opened this issue · comments

Webtty is awesome. Thank you! I'm trying to use it with Azure Pipelines but unfortunately, the connection data string is truncated in the logs. Is it possible to add a parameter to wrap the output?
Or perhaps you have a suggestion about a different way to solve this? Usually, there is a "view raw log" option in Azure Pipelines but that option is not visible because the task (./webtty -o -ni) is still running.

If I can cancel the pipeline then I can see the entire string but that is not useful because the host connection has now closed.

CleanShot 2022-10-25 at 3 08 02@2x

Managed to get this working by using a node script on the host machine that wraps the output:

const { spawn } = require("node:child_process");

const command = spawn("./webtty", ["-o", "-ni"]);

// wrap input string to 80 characters in length
function wrapTo80Chars(str) {
  let result = "";
  for (let i = 0; i < str.length; i += 80) {
    result += str.slice(i, i + 80) + "\r";
  }
  return result;
}

// the `data` event is fired every time data is
// output from the command
command.stdout.on("data", (output) => {
  // the output data is captured and printed in the callback
  console.log(wrapTo40Chars(output.toString()));
});