Skip to content

Commit

Permalink
Use the third line instead of second
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Nov 9, 2024
1 parent 7018b93 commit e2b1f19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion plugins/log/api-iife.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions plugins/log/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function getCallerLocation(stack?: string) {
// at filename.js:13:1

const lines = stack.split('\n')
// Find the second line (caller of the current location)
const callerLine = lines[2].trim()
// Find the third line (caller's caller of the current location)
const callerLine = lines[3].trim()

const regex =
/at\s+(?<functionName>.*?)\s+\((?<fileName>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+)\)/
Expand Down Expand Up @@ -99,10 +99,11 @@ function getCallerLocation(stack?: string) {
// global [email protected]:13:4

const traces = stack.split('\n').map((line) => line.split('@'))
const filtered = traces?.filter(([name, location]) => {
const filtered = traces.filter(([name, location]) => {
return name.length > 0 && location !== '[native code]'
})
return filtered?.[1]?.filter((v) => v.length > 0).join('@')
// Find the third line (caller's caller of the current location)
return filtered[2].filter((v) => v.length > 0).join('@')
}
}

Expand Down

0 comments on commit e2b1f19

Please sign in to comment.