Skip to content

Commit

Permalink
nicer debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
lubieowoce committed Dec 6, 2024
1 parent 2bf6bb5 commit 981f9b9
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions packages/next/src/server/after/stitch-after-callstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,37 @@ export function stitchAfterCallstack(
replaceErrorStack(error, frames)
}

console.log('AfterContext :: patchAfterCallstack', {
errorStack: origErrorStack,
nestedTaskCallerStacks: stackInfo.nestedTaskCallerStacks?.map(
console.log('='.repeat(60))
console.log('AfterContext :: stitchAfterCallstack')
const indent = (depth: number, str: string) =>
str
.split('\n')
.map((line) => ' '.repeat(depth) + line)
.join('\n')
const stackToStr = (str: string | null | undefined) =>
indent(4, !str ? inspect(str) : str)
console.log(' errorStack:')
console.log(stackToStr(origErrorStack))
console.log(
' nestedTaskCallerStacks:',
...(!stackInfo.nestedTaskCallerStacks
? [stackInfo.nestedTaskCallerStacks]
: [])
)
if (stackInfo.nestedTaskCallerStacks) {
for (const stack of stackInfo.nestedTaskCallerStacks?.map(
(e) => e?.stack
),
rootTaskCallerStack: stackInfo.rootTaskCallerStack?.stack,
rootTaskReactOwnerStack: stackInfo.rootTaskReactOwnerStack,
finalStack: frames ? error.stack : '<unchanged>',
})
)) {
console.log(stackToStr(stack))
}
}
console.log(' rootTaskCallerStack:')
console.log(stackToStr(stackInfo.rootTaskCallerStack?.stack))
console.log(' rootTaskReactOwnerStack:')
console.log(stackToStr(stackInfo.rootTaskReactOwnerStack))
console.log(' finalStack:')
console.log(stackToStr(frames ? error.stack : '<unchanged>'))
console.log('='.repeat(60))

return error
}
Expand Down

0 comments on commit 981f9b9

Please sign in to comment.