Skip to content

Commit c286cc0

Browse files
author
Luca Forstner
committed
no redos thx
1 parent 552727b commit c286cc0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/wasm/src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const _wasmIntegration = (() => {
3636

3737
export const wasmIntegration = defineIntegration(_wasmIntegration);
3838

39+
const PARSER_REGEX = /^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/;
40+
3941
/**
4042
* Patches a list of stackframes with wasm data needed for server-side symbolication
4143
* if applicable. Returns true if the provided list of stack frames had at least one
@@ -49,17 +51,19 @@ export function patchFrames(frames: Array<StackFrame>): boolean {
4951
return;
5052
}
5153

52-
// I will call this first match a "messy match".
54+
const split = frame.filename.split('(');
55+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
56+
const lastSplit = split[split.length - 1]!;
57+
58+
// Let's call this first match a "messy match".
5359
// The browser stacktrace parser spits out frames that have a filename like this: "int) const (http://localhost:8001/main.wasm:wasm-function[190]:0x5aeb"
54-
// It contains some leftover mess because wasm stackframes are more complicated than our parser can handle: "at MyClass::bar(int) const (http://localhost:8001/main.wasm:wasm-function[190]:0x5aeb)"
60+
// It contains some leftover mess because wasm stack frames are more complicated than our parser can handle: "at MyClass::bar(int) const (http://localhost:8001/main.wasm:wasm-function[190]:0x5aeb)"
5561
// This first match simply tries to mitigate the mess up until the first opening parens.
5662
// The match afterwards is a sensible fallback
57-
let match = frame.filename.match(/^.*\((.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/) as
58-
| null
59-
| [string, string, string];
63+
let match = lastSplit.match(PARSER_REGEX) as null | [string, string, string];
6064

6165
if (!match) {
62-
match = frame.filename.match(/^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/) as null | [string, string, string];
66+
match = frame.filename.match(PARSER_REGEX) as null | [string, string, string];
6367
}
6468

6569
if (match) {

0 commit comments

Comments
 (0)