Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/log-caller-location-throw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"log": patch
"log-js": patch
---

Make log functions omit caller location when failed to parse it instead of throwing
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.

7 changes: 5 additions & 2 deletions plugins/log/guest-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ function getCallerLocation(stack?: string) {

const lines = stack.split('\n')
// Find the third line (caller's caller of the current location)
const callerLine = lines[3].trim()
const callerLine = lines[3]?.trim()
if (!callerLine) {
return
}

const regex =
/at\s+(?<functionName>.*?)\s+\((?<fileName>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+)\)/
Expand Down Expand Up @@ -103,7 +106,7 @@ function getCallerLocation(stack?: string) {
return name.length > 0 && location !== '[native code]'
})
// Find the third line (caller's caller of the current location)
return filtered[2].filter((v) => v.length > 0).join('@')
return filtered[2]?.filter((v) => v.length > 0).join('@')
}
}

Expand Down
Loading