Skip to content

Instantly share code, notes, and snippets.

View kyle-villeneuve's full-sized avatar
🚀

Kyle Villeneuve kyle-villeneuve

🚀
View GitHub Profile
@kyle-villeneuve
kyle-villeneuve / decodeErrorStackTrace.ts
Created March 25, 2022 23:29
Decode client error stacktrace
import { STATIC_ASSETS_PATH } from '@skusavvy/config';
import { readFileSync } from 'fs';
import { join } from 'path';
import { NullableMappedPosition, SourceMapConsumer } from 'source-map';
type ParsedLocation = { file: string; line: number; column: number; token: string };
type ParsedStack = { message: string; files: Record<string, ParsedLocation[]> };
const RE_TOKENIZE_STACK_ITEM = /at (\w+) \((https?:\/\/[\w\.\d]+(:\d+)?)\/([\/\w\.]+):(\d+):(\d+)\)/g;