diff --git a/src/codegen/bindgen-lib-internal.ts b/src/codegen/bindgen-lib-internal.ts index 7c4ee555fa49c2..f969c30fd11954 100644 --- a/src/codegen/bindgen-lib-internal.ts +++ b/src/codegen/bindgen-lib-internal.ts @@ -886,7 +886,9 @@ function snapshotCallerLocation(): string { } function stackTraceFileName(line: string): string { - return / \(((?:[A-Za-z]:)?.*?)[:)]/.exec(line)![1].replaceAll("\\", "/"); + const match = /(?:at\s+|\()(.:?[^:\n(\)]*)[^(\n]*$/i.exec(line); + assert(match, `Couldn't extract filename from stack trace line: ${line}`); + return match[1].replaceAll("\\", "/"); } export type CAbiType =