Bug 1: bus-publisher.ts — reconnecting flag set BEFORE init completes
File: src/bus-publisher.ts lines 55–59
Problem: this.reconnecting = false is set before await this.init() completes. If init fails, reconnect is permanently disabled because the flag is already false.
Current code:
} catch {
this.bus = null;
if (!this.reconnecting) {
this.reconnecting = true;
setTimeout(async () => {
this.reconnecting = false; // BUG: set to false BEFORE init
await this.init({ onWarn: this.onWarn }); // if init fails, reconnect is permanently disabled
}, 5000);
}
}
Fix: Only set this.reconnecting = false AFTER init succeeds.
Bug 2: four-opencode-token-budget-guard.ts — JSON.stringify without try/catch
File: src/four-opencode-token-budget-guard.ts line 38
Problem: JSON.stringify is called without a try/catch, so circular references will throw and crash the logger.
Current code:
extra: { details: args.map(a => typeof a === 'object' ? JSON.stringify(a) : String(a)).join(" ") }
Fix: Wrap JSON.stringify in try/catch and return "[unserializable]" on failure.
Bug 1: bus-publisher.ts — reconnecting flag set BEFORE init completes
File:
src/bus-publisher.tslines 55–59Problem:
this.reconnecting = falseis set beforeawait this.init()completes. If init fails, reconnect is permanently disabled because the flag is already false.Current code:
Fix: Only set
this.reconnecting = falseAFTER init succeeds.Bug 2: four-opencode-token-budget-guard.ts — JSON.stringify without try/catch
File:
src/four-opencode-token-budget-guard.tsline 38Problem:
JSON.stringifyis called without a try/catch, so circular references will throw and crash the logger.Current code:
Fix: Wrap JSON.stringify in try/catch and return
"[unserializable]"on failure.