-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Problem
As identified in PR #136 code review, there's an edge case where init() can silently succeed after a partial failure.
Scenario:
doInit()spawns workers successfullyrefreshBridgeInfo()fails (e.g., network timeout)- On retry,
init()seesprocessPool.length >= minProcessesand returns early - Bridge appears initialized but
bridgeInfois undefined
Current Behavior
async init(): Promise<void> {
if (this.disposed) {
throw new BridgeDisposedError('Bridge has been disposed');
}
if (this.processPool.length >= this.options.minProcesses) {
return; // Early return based only on pool size
}
// ...
}Proposed Fix
Track initialization state explicitly:
private initState: 'pending' | 'initializing' | 'ready' | 'failed' = 'pending';
async init(): Promise<void> {
if (this.disposed) {
throw new BridgeDisposedError('Bridge has been disposed');
}
if (this.initState === 'ready') {
return;
}
if (this.initState === 'failed') {
throw new BridgeProtocolError('Bridge initialization previously failed');
}
// ...
}Impact
Low - bridgeInfo is diagnostic-only and workers remain functional even if metadata fetch fails.
References
- PR refactor: unify NodeBridge and OptimizedNodeBridge (ADR-0001) #136 CodeRabbit review comment
- Related to ADR-0001 bridge unification
Metadata
Metadata
Assignees
Labels
No labels