UNPKG

@dudousxd/nestjs-telescope

Version:

Laravel Telescope-style observability console for NestJS — core: watchers, recorder, correlation, SQLite store, headless API.

32 lines 1.37 kB
// packages/core/src/entry/exception-family-hash.ts /** * Extract the first stack FRAME line (the deepest call site), skipping the * leading `Name: message` header that V8 and most browsers prepend. Returns an * empty string when no frame line is present, so the family key degrades to * name+message rather than throwing. */ function topStackFrame(stack) { if (stack === null) return ''; for (const rawLine of stack.split('\n')) { const line = rawLine.trim(); // The first line is usually the `Error: message` header (no `at `). Frame // lines start with `at ` in V8; browsers vary, so also accept an `@`-form // (Firefox/Safari: `fn@url:line:col`). Take the first that looks like a frame. if (line.startsWith('at ') || line.includes('@')) { return line; } } return ''; } /** * Build the stable family hash for an exception/client-error from its name, * message and top stack frame. Pure string concatenation (no hashing) keeps it * human-readable in the dashboard and trivially equal across the server * interceptor and the client-error controller, which both call this. */ export function exceptionFamilyHash(parts) { const frame = topStackFrame(parts.stack); return `${parts.name}:${parts.message}:${frame}`; } //# sourceMappingURL=exception-family-hash.js.map