Skip to content

Commit

Permalink
Fix incorrect stack frame assumption
Browse files Browse the repository at this point in the history
  • Loading branch information
jdylanstewart committed Aug 3, 2022
1 parent 52d336f commit 96fb6c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/UserCodeRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,13 @@ export class UserCodeRuntimeError extends UserCodeError {

public get location(): { line: number; column: number } {
const stack = parse(this.error);
const userFileStackFrame = stack.find(callSite => callSite.getFileName() === USER_CODE_FILENAME);
if (userFileStackFrame === undefined) {
throw new Error('Runtime error detected outside of user code execution path. This is most likely a bug in the additional library source.');
}
const originalPosition = this.sourceMap.originalPositionFor({
line: stack[0].getLineNumber()!,
column: stack[0].getColumnNumber()!,
line: userFileStackFrame.getLineNumber()!,
column: userFileStackFrame.getColumnNumber()!,
});
return {
line: originalPosition.line!,
Expand Down

0 comments on commit 96fb6c6

Please sign in to comment.