Problem
The module-level debugLogger in debug/index.ts is initialized to a set of noop functions that return empty DebugEvent stubs. Any code that calls getDebugLogger().error(...) (or any other level) before initDebugLogger(...) runs has its event silently dropped — no warning, no console output, nothing. Given that getDebugLogger has 50+ call sites across the main process (gateway-client, auto-updater, tray, quick-launch, workspace init, etc.), it is easy for a module-level or early-startup error to disappear without a trace, making real incidents invisible during the window that matters most (app boot).
Location
File: packages/desktop/src/main/debug/index.ts:6-15
const noop = (): DebugEvent => ({ ts: '', level: 'debug', domain: 'app', event: '' }) as DebugEvent;
let debugLogger: DebugLogger = {
debug: noop,
info: noop,
warn: noop,
error: noop,
log: noop,
getRecentEvents: () => [],
currentFilePath: () => '',
};
Fix Approach
Pick one of, in order of increasing investment:
- Minimum: replace the noop stubs with variants that
console.warn whenever called before init — noop = (input) => { console.warn('[debug] logger not initialized, dropping event:', input); return stub; }. The log won't end up in the ndjson file, but at least the developer sees it in the terminal.
- Better: buffer events in an in-memory queue until
initDebugLogger runs, then flush the queue into the real logger. Cap the queue at a small size (e.g. 256) to prevent unbounded pre-init allocation.
Option 2 is the fully correct fix; option 1 is a one-liner that catches the common case.
Verification
- Run
pnpm check — must pass.
- Unit test: call
getDebugLogger().error(...) before initDebugLogger, then call init, then assert the earlier event appears in the real logger (option 2) or that a console warning was emitted (option 1).
Context
- WG: Observability & DX
- Priority: Low (good first issue)
- Estimated effort: 15-30 minutes (option 1) / 1 hour (option 2)
Problem
The module-level
debugLoggerindebug/index.tsis initialized to a set of noop functions that return emptyDebugEventstubs. Any code that callsgetDebugLogger().error(...)(or any other level) beforeinitDebugLogger(...)runs has its event silently dropped — no warning, no console output, nothing. Given thatgetDebugLoggerhas 50+ call sites across the main process (gateway-client, auto-updater, tray, quick-launch, workspace init, etc.), it is easy for a module-level or early-startup error to disappear without a trace, making real incidents invisible during the window that matters most (app boot).Location
File:
packages/desktop/src/main/debug/index.ts:6-15Fix Approach
Pick one of, in order of increasing investment:
console.warnwhenever called before init —noop = (input) => { console.warn('[debug] logger not initialized, dropping event:', input); return stub; }. The log won't end up in the ndjson file, but at least the developer sees it in the terminal.initDebugLoggerruns, then flush the queue into the real logger. Cap the queue at a small size (e.g. 256) to prevent unbounded pre-init allocation.Option 2 is the fully correct fix; option 1 is a one-liner that catches the common case.
Verification
pnpm check— must pass.getDebugLogger().error(...)beforeinitDebugLogger, then call init, then assert the earlier event appears in the real logger (option 2) or that a console warning was emitted (option 1).Context