fix(unified-session): address code review feedback
Fixes 3 issues identified in code review: 1. ENV VAR PRECEDENCE: Changed DEFAULT_CONNECTION_CONFIG to use undefined for enableUnifiedSession, allowing env var BAILEYS_UNIFIED_SESSION_ENABLED to take precedence. Priority is now: explicit config > env var > default (true) 2. SINGLE INITIALIZATION: UnifiedSessionManager is now created only once, after sendNode is defined. This avoids: - Duplicate circuit breaker instances - State reinitialization - Unnecessary overhead and logs 3. CONTINUOUS TIME SYNC: serverTimeOffset is now updated on every received frame that contains a 't' attribute, not just on CB:success. This keeps the offset accurate even during long-running connections.
This commit is contained in:
@@ -108,7 +108,9 @@ export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
|
||||
// + 10 buffer slots for high-load scenarios = 50 total
|
||||
maxSocketClientListeners: 50,
|
||||
// Unified session telemetry (reduces detection of unofficial clients)
|
||||
enableUnifiedSession: true
|
||||
// NOTE: undefined means "check env var first, then default to true"
|
||||
// This allows BAILEYS_UNIFIED_SESSION_ENABLED env var to have precedence
|
||||
enableUnifiedSession: undefined
|
||||
}
|
||||
|
||||
export const MEDIA_PATH_MAP: { [T in MediaType]?: string } = {
|
||||
|
||||
Reference in New Issue
Block a user