fix: address
fix: address
This commit is contained in:
@@ -30,6 +30,12 @@ console.log = function(...args: unknown[]) {
|
|||||||
if (args.length > 0 && typeof args[0] === 'string') {
|
if (args.length > 0 && typeof args[0] === 'string') {
|
||||||
const msg = args[0]
|
const msg = args[0]
|
||||||
|
|
||||||
|
// Check if this log comes from libsignal by examining the call stack
|
||||||
|
// This prevents suppressing unrelated logs from other modules
|
||||||
|
const stack = new Error().stack || ''
|
||||||
|
const isFromLibsignal = stack.includes('libsignal') || stack.includes('session_cipher')
|
||||||
|
|
||||||
|
if (isFromLibsignal) {
|
||||||
// Suppress session lifecycle dumps (cryptographic details on every encrypt/decrypt)
|
// Suppress session lifecycle dumps (cryptographic details on every encrypt/decrypt)
|
||||||
if (msg.startsWith('Closing session')) {
|
if (msg.startsWith('Closing session')) {
|
||||||
return
|
return
|
||||||
@@ -48,6 +54,7 @@ console.log = function(...args: unknown[]) {
|
|||||||
return // suppress - our retry system handles these gracefully
|
return // suppress - our retry system handles these gracefully
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_origConsoleLog.apply(console, args)
|
_origConsoleLog.apply(console, args)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -405,12 +405,10 @@ export const decryptMessageNode = (
|
|||||||
...(isRetryExhausted && { retriesExhausted: true, attempts: err.attempts })
|
...(isRetryExhausted && { retriesExhausted: true, attempts: err.attempts })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Smart logging: Only show ERROR on final failure
|
// Smart logging based on error type and retry status
|
||||||
// During retries, libsignal may log internally - we can't suppress those
|
|
||||||
// But we can avoid adding our own duplicate error logs for each retry
|
|
||||||
if (isCorrupted) {
|
if (isCorrupted) {
|
||||||
// Corrupted session errors are expected and auto-recovered
|
// Corrupted session errors are expected and auto-recovered
|
||||||
// Only log as ERROR if this is the final failure after all retries
|
// Only log as ERROR if retries exhausted, otherwise WARN on first attempt
|
||||||
if (isRetryExhausted) {
|
if (isRetryExhausted) {
|
||||||
logger.error(
|
logger.error(
|
||||||
errorContext,
|
errorContext,
|
||||||
@@ -450,9 +448,10 @@ export const decryptMessageNode = (
|
|||||||
logger.debug(errorContext, 'No session record - will retry')
|
logger.debug(errorContext, 'No session record - will retry')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unknown/unexpected error - always log as error
|
// Unknown/unexpected errors (protobuf, parsing, etc.)
|
||||||
const logLevel = isRetryExhausted ? 'error' : 'warn'
|
// These don't go through retry, so always log as ERROR
|
||||||
logger[logLevel](
|
// Type-safe explicit logging instead of dynamic property access
|
||||||
|
logger.error(
|
||||||
errorContext,
|
errorContext,
|
||||||
isRetryExhausted
|
isRetryExhausted
|
||||||
? `Failed to decrypt message after ${err.attempts} attempts`
|
? `Failed to decrypt message after ${err.attempts} attempts`
|
||||||
@@ -461,7 +460,8 @@ export const decryptMessageNode = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
|
fullMessage.messageStubType = proto.WebMessageInfo.StubType.CIPHERTEXT
|
||||||
fullMessage.messageStubParameters = [originalError.message.toString()]
|
// Safe coercion handling edge cases where message might be undefined
|
||||||
|
fullMessage.messageStubParameters = [String(originalError?.message ?? originalError)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user