(frame: unknown)
| 266 | |
| 267 | /** Inbound server frame — control frames and event frames alike. */ |
| 268 | export function traceWsIn(frame: unknown): void { |
| 269 | if (!isTraceEnabled()) return; |
| 270 | const f = (frame ?? {}) as Record<string, unknown>; |
| 271 | const type = typeof f['type'] === 'string' ? (f['type'] as string) : '(unknown)'; |
| 272 | const sessionId = |
| 273 | typeof f['session_id'] === 'string' |
| 274 | ? (f['session_id'] as string) |
| 275 | : typeof (f['payload'] as Record<string, unknown> | undefined)?.['session_id'] === 'string' |
| 276 | ? ((f['payload'] as Record<string, unknown>)['session_id'] as string) |
| 277 | : undefined; |
| 278 | const seq = typeof f['seq'] === 'number' ? (f['seq'] as number) : undefined; |
| 279 | const offset = typeof f['offset'] === 'number' ? (f['offset'] as number) : undefined; |
| 280 | const bits = [ |
| 281 | sessionId, |
| 282 | seq !== undefined ? `seq=${seq}` : undefined, |
| 283 | offset !== undefined ? `offset=${offset}` : undefined, |
| 284 | f['volatile'] === true ? 'volatile' : undefined, |
| 285 | ].filter(Boolean); |
| 286 | push({ |
| 287 | source: 'ws', |
| 288 | kind: 'ws:in', |
| 289 | eventType: type, |
| 290 | sessionId, |
| 291 | seq, |
| 292 | offset, |
| 293 | label: `← ${type}${bits.length > 0 ? ` (${bits.join(' ')})` : ''}`, |
| 294 | detail: detailOf(f['payload']), |
| 295 | }); |
| 296 | } |
| 297 | |
| 298 | // --------------------------------------------------------------------------- |
| 299 | // Client-side log capture — so the exported troubleshooting log includes the |
no test coverage detected