Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(cli): keep Chromium's logging off the CLI's stdout

EtienneLescot8a6d4c391dc7
diff --git a/electron/cli/cliMain.ts b/electron/cli/cliMain.ts
index b5f02afdf..53478de48 100644
--- a/electron/cli/cliMain.ts
+++ b/electron/cli/cliMain.ts
@@ -13,6 +13,7 @@ import type {
CliRequest,
CliSourcesResult,
} from "../../src/lib/cliContracts";
+import { isDiagnosticModeEnabled } from "../diagnostics/main-log-buffer";
import { getSelectedDesktopSource, registerIpcHandlers } from "../ipc/handlers";
import { registerSttIpc } from "../stt";
import { ASSET_BASE_URL_ARG } from "../windows";
@@ -272,6 +273,21 @@ export function runCli(command: CliCommand): void {
// so the WebGL-based export renderer still works.
app.commandLine.appendSwitch("enable-unsafe-swiftshader");
+ // Chromium's own C++ logging writes to stdout, and for this process stdout is
+ // the CLI's data channel. On a host with no dbus and no GPU -- CI, a server,
+ // a container -- `openscreen sources --json` emits a wall of
+ // [pid:...:ERROR:dbus/bus.cc:405] ahead of the JSON, and every consumer
+ // downstream chokes on it. Headless is precisely where --json earns its keep,
+ // so stdout has to carry the CLI's output and nothing else.
+ //
+ // console.* is already rerouted to stderr above, but that only covers the JS
+ // side; native logging never passes through Node's streams and needs the
+ // switch. Diagnostic runs keep it: seeing more is the point of that flag, and
+ // such a run is not being piped into jq.
+ if (!isDiagnosticModeEnabled()) {
+ app.commandLine.appendSwitch("disable-logging");
+ }
+
// Never show the dock icon for CLI runs.
if (process.platform === "darwin") {
app.dock?.hide();