chore(observability): defensive depth pass

Two related cleanups so unexpected failures stop being invisible:

void-promise wrappers
  Every `void this.something()` fire-and-forget call now has a
  .catch(err => log.warn(...)) attached. Affected sites:
    - packet-pipeline.ts: dispatchAfterIdentityRefresh
    - instance.ts: openAll / applyConfigDiff / closeAll / emitEvent
    - http-post-adapter.ts: postEvent
    - ws-client-adapter.ts: handleApiMessage
  Most of the network-manager fan-outs already isolate per-adapter
  errors, but the outer catches guard against future refactors and
  surface stack traces immediately rather than as unhandled rejection
  warnings.

silent-catch sweep (Bridge.Web)
  bridge/web/group-honor.ts, group-essence.ts, group-notice.ts had
  `} catch (e) { return undefined; }` patterns that turned every QQ
  Web API failure into a silent empty response. Now log.warn with
  the full stack first, then return the same fallback so behavior is
  unchanged. The commented-out `// console.error(e)` debris is gone.

Plus one console → logger conversion in message-parser.ts (music
sign fallback path).
This commit is contained in:
DrSmoothl committed 2026-05-18 01:36:12 +08:00
1 parent 7ec479bb88
commit 84e746c278
8 files changed
+53 -16

No files matched your search

+4 -1
View File
@@ -4,6 +4,9 @@
import type { MessageElement } from '../bridge/events';
import type { JsonValue, JsonObject } from './types';
import { createLogger } from '../utils/logger';
const log = createLogger('MsgParser');
export interface ParseMessageOptions {
resolveReplySequence?: (replyMessageId: number) => number | null;
@@ -271,7 +274,7 @@ async function segmentToElement(type: string, data: Record<string, unknown>, opt
const musicJson = await resp.text();
return { type: 'json', text: musicJson };
} catch (e) {
console.warn(`[MsgParser] music sign failed: ${e}, falling back to local card`);
log.warn('music sign failed: %s, falling back to local card', e instanceof Error ? e.message : String(e));
// Fallback: build a basic card locally
const title = String(data.title ?? 'Music');
const jsonData = JSON.stringify({