Skip to content

Commit 66df549

Browse files
committed
feat[bc]: route worker stderr through the logger so native logs are silent by default
Signed-off-by: Arun Mani J <j.arunmani@proton.me>
1 parent 2b7f19e commit 66df549

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/sdk/client/rpc/node-rpc-client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import path from "node:path";
1212
import { fileURLToPath } from "node:url";
1313
import { initializeConfig } from "@/client/init-hooks";
1414
import { resolveConfig } from "@/client/config-loader/resolve-config.node";
15-
import { getClientLogger } from "@/logging";
15+
import { getClientLogger, getLogger, SDK_SERVER_NAMESPACE } from "@/logging";
1616
import {
1717
BareRuntimeBinaryNotFoundError,
1818
RPCInitTimeoutError,
@@ -25,6 +25,9 @@ const RPC_INIT_TIMEOUT_MS = 30_000;
2525
const WORKER_STDERR_TAIL_CHARS = 16_384;
2626

2727
const logger = getClientLogger();
28+
// Addons route real logs through their JS callback; anything written straight to the
29+
// worker's stderr is treated as debug.
30+
const workerLogger = getLogger(SDK_SERVER_NAMESPACE, { enableConsole: false });
2831

2932
let rpcInstance: RPC | null = null;
3033
let rpcPromise: Promise<RPC> | null = null;
@@ -418,7 +421,9 @@ async function ensureRPC(): Promise<RPC> {
418421
getWorkerStderr(bareWorkerProc)?.on("data", (chunk) => {
419422
const text = chunk.toString();
420423
workerStderrTail = appendWorkerStderrTail(workerStderrTail, text);
421-
process.stderr.write(chunk);
424+
for (const line of text.split("\n")) {
425+
if (line.trim()) workerLogger.debug(line);
426+
}
422427
});
423428

424429
bareWorkerProc.on(

0 commit comments

Comments
 (0)