[Bug] getDebugLogger noop fallback silently drops events before initDebugLogger runs
#412 opened on Apr 15, 2026
Repository metrics
- Stars
- (519 stars)
- PR merge metrics
- (PR metrics pending)
Description
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.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. - Better: buffer events in an in-memory queue until
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
- Run
pnpm check— must pass. - Unit test: call
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
- WG: Observability & DX
- Priority: Low (good first issue)
- Estimated effort: 15-30 minutes (option 1) / 1 hour (option 2)