Browse Source

reduce console noise

imwald
Silberengel 3 weeks ago
parent
commit
04d3829c0e
  1. 4
      src/components/NoteList/index.tsx
  2. 66
      src/lib/error-suppression.ts
  3. 2
      src/lib/index-relay-http.ts
  4. 10
      src/providers/NostrProvider/index.tsx
  5. 2
      src/services/client.service.ts
  6. 8
      src/services/relay-operation-log.service.ts

4
src/components/NoteList/index.tsx

@ -1018,7 +1018,7 @@ const NoteList = forwardRef(
if (feedPaintSessionPendingRef.current) { if (feedPaintSessionPendingRef.current) {
feedPaintSessionPendingRef.current = false feedPaintSessionPendingRef.current = false
logger.info('[FeedPaint] Session cache committed (DOM)', { logger.debug('[FeedPaint] Session cache committed (DOM)', {
feedKey: feedKeyShort, feedKey: feedKeyShort,
snapshotKey: snapshotKeyShort, snapshotKey: snapshotKeyShort,
eventCount: events.length, eventCount: events.length,
@ -1030,7 +1030,7 @@ const NoteList = forwardRef(
feedPaintRelayPendingRef.current = false feedPaintRelayPendingRef.current = false
const meta = feedPaintRelayMetaRef.current const meta = feedPaintRelayMetaRef.current
feedPaintRelayMetaRef.current = null feedPaintRelayMetaRef.current = null
logger.info('[FeedPaint] Relay/network results committed (DOM)', { logger.debug('[FeedPaint] Relay/network results committed (DOM)', {
feedKey: feedKeyShort, feedKey: feedKeyShort,
snapshotKey: snapshotKeyShort, snapshotKey: snapshotKeyShort,
committedEventCount: events.length, committedEventCount: events.length,

66
src/lib/error-suppression.ts

@ -18,11 +18,14 @@ export function suppressExpectedErrors() {
return return
} }
// Suppress CORS errors for external websites // Suppress CORS errors for external websites (EN + DE Firefox strings)
if (message.includes('CORS policy') || if (message.includes('CORS policy') ||
message.includes('Access-Control-Allow-Origin') || message.includes('Access-Control-Allow-Origin') ||
message.includes('has been blocked by CORS policy') || message.includes('has been blocked by CORS policy') ||
message.includes('blocked by CORS policy') || message.includes('blocked by CORS policy') ||
message.includes('Quellübergreifende') ||
message.includes('Gleiche-Quelle-Regel') ||
message.includes('Cross-Origin') && message.includes('blockiert') ||
(message.includes('Access to fetch at') && message.includes('has been blocked')) || (message.includes('Access to fetch at') && message.includes('has been blocked')) ||
(message.includes('from origin') && message.includes('has been blocked'))) { (message.includes('from origin') && message.includes('has been blocked'))) {
return return
@ -128,7 +131,20 @@ export function suppressExpectedErrors() {
(message.includes('fehlgeschlagen') && message.includes('URI')) || (message.includes('fehlgeschlagen') && message.includes('URI')) ||
message.includes('Laden der Medienressource') || message.includes('Laden der Medienressource') ||
message.includes('Failed to load media resource') || message.includes('Failed to load media resource') ||
message.includes('OpaqueResponseBlocking')) { message.includes('OpaqueResponseBlocking') ||
(message.includes('image/svg+xml') &&
(message.includes('nicht unterstützt') ||
message.includes('Keine Decoder') ||
message.includes('Medien können nicht'))) ||
message.includes('A resource is blocked by OpaqueResponseBlocking')) {
return
}
// Firefox: failed WS to dead local/dev relays (wording varies by locale)
if (
message.includes('kann keine Verbindung') &&
(message.includes('WebSocket') || message.includes('ws://') || message.includes('wss://'))
) {
return return
} }
@ -158,7 +174,31 @@ export function suppressExpectedErrors() {
message.includes('Medienressource') || message.includes('Medienressource') ||
(message.includes('fehlgeschlagen') && message.includes('URI')) || (message.includes('fehlgeschlagen') && message.includes('URI')) ||
message.includes('Laden der Medienressource') || message.includes('Laden der Medienressource') ||
message.includes('Failed to load media resource')) { message.includes('Failed to load media resource') ||
message.includes('OpaqueResponseBlocking') ||
message.includes('A resource is blocked by OpaqueResponseBlocking') ||
(message.includes('image/svg+xml') &&
(message.includes('nicht unterstützt') ||
message.includes('Keine Decoder') ||
message.includes('Medien können nicht')))) {
return
}
// German Firefox CORS (same-origin policy)
if (message.includes('Quellübergreifende') ||
message.includes('Gleiche-Quelle-Regel') ||
(message.includes('Cross-Origin') && message.includes('blockiert'))) {
return
}
if (
message.includes('kann keine Verbindung') &&
(message.includes('WebSocket') || message.includes('ws://') || message.includes('wss://'))
) {
return
}
if (message.includes('NS_BINDING_ABORTED')) {
return return
} }
@ -187,11 +227,14 @@ export function suppressExpectedErrors() {
return return
} }
// Suppress CORS policy warnings // Suppress CORS policy warnings (EN + DE)
if (message.includes('CORS policy') || if (message.includes('CORS policy') ||
message.includes('Access-Control-Allow-Origin') || message.includes('Access-Control-Allow-Origin') ||
message.includes('has been blocked by CORS policy') || message.includes('has been blocked by CORS policy') ||
message.includes('blocked by CORS policy') || message.includes('blocked by CORS policy') ||
message.includes('Quellübergreifende') ||
message.includes('Gleiche-Quelle-Regel') ||
(message.includes('Cross-Origin') && message.includes('blockiert')) ||
(message.includes('Access to fetch') && message.includes('blocked')) || (message.includes('Access to fetch') && message.includes('blocked')) ||
(message.includes('from origin') && message.includes('blocked'))) { (message.includes('from origin') && message.includes('blocked'))) {
return return
@ -222,7 +265,8 @@ export function suppressExpectedErrors() {
if (message.includes('NOTICE from') || if (message.includes('NOTICE from') ||
message.includes('Too many subscriptions') || message.includes('Too many subscriptions') ||
message.includes('Subscription rejected') || message.includes('Subscription rejected') ||
message.includes('too many concurrent REQs')) { message.includes('too many concurrent REQs') ||
message.includes('too many kinds')) {
return return
} }
@ -255,7 +299,13 @@ export function suppressExpectedErrors() {
if (message.includes('NOTICE from') || if (message.includes('NOTICE from') ||
message.includes('Too many subscriptions') || message.includes('Too many subscriptions') ||
message.includes('Subscription rejected') || message.includes('Subscription rejected') ||
message.includes('too many concurrent REQs')) { message.includes('too many concurrent REQs') ||
message.includes('too many kinds')) {
return
}
// Nostr browser extensions (signing / debug)
if (message.includes('[nos2x') || message.includes('nos2x-fox:')) {
return return
} }

2
src/lib/index-relay-http.ts

@ -90,7 +90,7 @@ function maybeLogDevIndexRelayUnreachableHint(): void {
const now = Date.now() const now = Date.now()
if (now - lastDevIndexRelayTransportHintAt < DEV_INDEX_RELAY_TRANSPORT_HINT_MS) return if (now - lastDevIndexRelayTransportHintAt < DEV_INDEX_RELAY_TRANSPORT_HINT_MS) return
lastDevIndexRelayTransportHintAt = now lastDevIndexRelayTransportHintAt = now
logger.info( logger.debug(
'HTTP index relay is unreachable in dev. Start the relay, or set VITE_DEV_INDEX_RELAY_TARGET if it is not on the default URL.' 'HTTP index relay is unreachable in dev. Start the relay, or set VITE_DEV_INDEX_RELAY_TARGET if it is not on the default URL.'
) )
} }

10
src/providers/NostrProvider/index.tsx

@ -140,7 +140,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
useEffect(() => { useEffect(() => {
const init = async () => { const init = async () => {
logger.info('[NostrProvider] Restoring session (login / first account)…') logger.debug('[NostrProvider] Restoring session (login / first account)…')
if (hasNostrLoginHash()) { if (hasNostrLoginHash()) {
return await loginByNostrLoginHash() return await loginByNostrLoginHash()
} }
@ -153,7 +153,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
} }
init() init()
.then(() => { .then(() => {
logger.info('[NostrProvider] Session restore finished; feeds and UI can initialize') logger.debug('[NostrProvider] Session restore finished; feeds and UI can initialize')
setIsInitialized(true) setIsInitialized(true)
}) })
.catch((e) => { .catch((e) => {
@ -221,7 +221,7 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
hydrationGenForThisRun = accountHydrationGenerationRef.current += 1 hydrationGenForThisRun = accountHydrationGenerationRef.current += 1
setIsAccountSessionHydrating(true) setIsAccountSessionHydrating(true)
logger.info('[NostrProvider] Account session hydrate: loading cache and relays…', { logger.debug('[NostrProvider] Account session hydrate: loading cache and relays…', {
pubkeySlice: account.pubkey.slice(0, 12), pubkeySlice: account.pubkey.slice(0, 12),
hydrationGen: hydrationGenForThisRun hydrationGen: hydrationGenForThisRun
}) })
@ -639,11 +639,11 @@ export function NostrProvider({ children }: { children: React.ReactNode }) {
storage.setAccountNetworkHydrateAt(account.pubkey, Date.now()) storage.setAccountNetworkHydrateAt(account.pubkey, Date.now())
void client.runSessionPrewarm({ pubkey: account.pubkey, signal: controller.signal }) void client.runSessionPrewarm({ pubkey: account.pubkey, signal: controller.signal })
logger.info('[NostrProvider] Account session hydrate: core relay/profile merge finished; client prewarm started (parallel)', { logger.debug('[NostrProvider] Account session hydrate: core relay/profile merge finished; client prewarm started (parallel)', {
pubkeySlice: account.pubkey.slice(0, 12) pubkeySlice: account.pubkey.slice(0, 12)
}) })
} else { } else {
logger.info('[NostrProvider] Skipped network hydrate (within min interval); IndexedDB cache only', { logger.debug('[NostrProvider] Skipped network hydrate (within min interval); IndexedDB cache only', {
pubkeySlice: account.pubkey.slice(0, 12), pubkeySlice: account.pubkey.slice(0, 12),
lastNetworkHydrateAt, lastNetworkHydrateAt,
ageMs: Date.now() - (lastNetworkHydrateAt ?? 0) ageMs: Date.now() - (lastNetworkHydrateAt ?? 0)

2
src/services/client.service.ts

@ -1700,7 +1700,7 @@ class ClientService extends EventTarget {
) { ) {
const timelineBatchId = `tl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 9)}` const timelineBatchId = `tl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 9)}`
const timelineT0 = performance.now() const timelineT0 = performance.now()
logger.info('[RelayOp] timeline_wave_begin', { logger.debug('[RelayOp] timeline_wave_begin', {
timelineBatchId, timelineBatchId,
shardCount: subRequests.length, shardCount: subRequests.length,
relayCountsPerShard: subRequests.map((r) => r.urls.length), relayCountsPerShard: subRequests.map((r) => r.urls.length),

8
src/services/relay-operation-log.service.ts

@ -135,7 +135,7 @@ function groupTerminalsByOutcome(rows: RelayOpTerminalRow[]): Record<string, { c
* Tracks one logical subscribe/query wave: one `batch_begin` and one `batch_end` with per-relay outcomes. * Tracks one logical subscribe/query wave: one `batch_begin` and one `batch_end` with per-relay outcomes.
*/ */
export type RelaySubscribeOpBatchOptions = { export type RelaySubscribeOpBatchOptions = {
/** `debug` hides high-volume query REQs unless jumble-debug / VITE_DEBUG is on. */ /** `info` logs every REQ wave at INFO; default `debug` keeps subscribe noise behind jumble-debug / VITE_DEBUG. */
logLevel?: 'info' | 'debug' logLevel?: 'info' | 'debug'
/** Invoked once when this REQ wave finishes (same `rows` as `batch_end` / `terminals`). */ /** Invoked once when this REQ wave finishes (same `rows` as `batch_end` / `terminals`). */
onBatchEnd?: (rows: RelayOpTerminalRow[]) => void onBatchEnd?: (rows: RelayOpTerminalRow[]) => void
@ -190,7 +190,7 @@ export class RelaySubscribeOpBatch {
this.t0 = typeof performance !== 'undefined' ? performance.now() : Date.now() this.t0 = typeof performance !== 'undefined' ? performance.now() : Date.now()
this.source = source this.source = source
this.grouped = grouped this.grouped = grouped
this.logLevel = options?.logLevel ?? 'info' this.logLevel = options?.logLevel ?? 'debug'
this.onBatchEnd = options?.onBatchEnd this.onBatchEnd = options?.onBatchEnd
} }
@ -329,7 +329,7 @@ export class RelayPublishOpBatch {
} }
logBegin(): void { logBegin(): void {
logger.info('[RelayOp] publish_batch_begin', { logger.debug('[RelayOp] publish_batch_begin', {
batchId: this.batchId, batchId: this.batchId,
source: this.source, source: this.source,
eventId: this.eventId, eventId: this.eventId,
@ -370,7 +370,7 @@ export class RelayPublishOpBatch {
] ]
.filter(Boolean) .filter(Boolean)
.join('\n') .join('\n')
logger.info('[RelayOp] publish_batch_end', { logger.debug('[RelayOp] publish_batch_end', {
batchId: this.batchId, batchId: this.batchId,
source: this.source, source: this.source,
eventId: this.eventId, eventId: this.eventId,

Loading…
Cancel
Save