Skip to content

Commit

Permalink
don't fetch with an empty list, fetch at the top level
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverb123 committed Nov 28, 2024
1 parent 3ab5e4e commit ba51249
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 12 additions & 6 deletions frontend/src/lib/components/Errors/ErrorDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ function StackTrace({
showAllFrames: boolean
}): JSX.Element | null {
const { stackFrameRecords } = useValues(stackFrameLogic)
const { loadFromRawIds } = useActions(stackFrameLogic)
const displayFrames = showAllFrames ? frames : frames.filter((f) => f.in_app)

useEffect(() => {
loadFromRawIds(frames.map(({ raw_id }) => raw_id))
}, [frames, loadFromRawIds])

const panels = displayFrames.map(
({ raw_id, source, line, column, resolved_name, lang, resolved, resolve_failure }, index) => {
const record = stackFrameRecords[raw_id]
Expand Down Expand Up @@ -122,8 +117,19 @@ function FrameContextLine({
}
function ChainedStackTraces({ exceptionList }: { exceptionList: ErrorTrackingException[] }): JSX.Element {
const hasAnyInApp = exceptionList.some(({ stacktrace }) => stacktrace?.frames?.some(({ in_app }) => in_app))

const [showAllFrames, setShowAllFrames] = useState(!hasAnyInApp)
const { loadFromRawIds } = useActions(stackFrameLogic)

useEffect(() => {
const frames: ErrorTrackingStackFrame[] = exceptionList.flatMap((e) => {
const trace = e.stacktrace
if (trace?.type === 'resolved') {
return trace.frames
}
return []
})
loadFromRawIds(frames.map(({ raw_id }) => raw_id))
}, [exceptionList, showAllFrames, setShowAllFrames, loadFromRawIds])

return (
<>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/lib/components/Errors/stackFrameLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const stackFrameLogic = kea<stackFrameLogicType>([
loadFromRawIds: async ({ rawIds }) => {
const loadedRawIds = Object.keys(values.stackFrameRecords)
rawIds = rawIds.filter((rawId) => !loadedRawIds.includes(rawId))
if (rawIds.length === 0) {
return values.stackFrameRecords
}
const { results } = await api.errorTracking.stackFrames(rawIds)
return mapStackFrameRecords(results, values.stackFrameRecords)
},
Expand Down

0 comments on commit ba51249

Please sign in to comment.