Always return original stack trace
This commit is contained in:
parent
be9b919b60
commit
c3c3fe1ccb
@ -11,13 +11,14 @@ const STACK_TRACE_LINE_REGEX = /^([A-Za-z0-9]*)@(.*):([0-9]+):([0-9]+)/
|
|||||||
*/
|
*/
|
||||||
export async function decodeMinifiedStackTrace (stack, sourceMaps = {}) {
|
export async function decodeMinifiedStackTrace (stack, sourceMaps = {}) {
|
||||||
let decodedStack = ''
|
let decodedStack = ''
|
||||||
|
let decoded = false
|
||||||
for (const line of stack.split('\n')) {
|
for (const line of stack.split('\n')) {
|
||||||
try {
|
try {
|
||||||
const stackLine = line.trim()
|
const stackLine = line.trim()
|
||||||
const stackLineParts = stackLine?.match(STACK_TRACE_LINE_REGEX)
|
const stackLineParts = stackLine?.match(STACK_TRACE_LINE_REGEX)
|
||||||
if (stackLineParts) {
|
if (stackLineParts) {
|
||||||
const [stackFile, stackLine, stackColumn] = stackLineParts.slice(2)
|
const [stackFile, stackLine, stackColumn] = stackLineParts.slice(2)
|
||||||
if (!stackFile || !stackLine || !stackColumn) throw new Error('Unsupported stack line ' + JSON.stringify(stackLineParts))
|
if (!stackFile || !stackLine || !stackColumn) throw new Error('Unsupported stack line')
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
!stackFile.startsWith(process.env.NEXT_PUBLIC_ASSET_PREFIX) &&
|
!stackFile.startsWith(process.env.NEXT_PUBLIC_ASSET_PREFIX) &&
|
||||||
@ -35,7 +36,9 @@ export async function decodeMinifiedStackTrace (stack, sourceMaps = {}) {
|
|||||||
column: parseInt(stackColumn)
|
column: parseInt(stackColumn)
|
||||||
})
|
})
|
||||||
const { source, name, line, column } = map
|
const { source, name, line, column } = map
|
||||||
|
if (!source || line === undefined) throw new Error('Unsupported stack line')
|
||||||
decodedStack += `${name || ''}@${source}:${line}:${column}\n`
|
decodedStack += `${name || ''}@${source}:${line}:${column}\n`
|
||||||
|
decoded = true
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -43,5 +46,10 @@ export async function decodeMinifiedStackTrace (stack, sourceMaps = {}) {
|
|||||||
}
|
}
|
||||||
decodedStack += `${line}\n`
|
decodedStack += `${line}\n`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (decoded) {
|
||||||
|
decodedStack = `Decoded stacktrace:\n${decodedStack}\n\nOriginal stack trace:\n${stack}`
|
||||||
|
}
|
||||||
|
|
||||||
return decodedStack
|
return decodedStack
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user