Skip to content

Commit

Permalink
Handle lack of point.frame (#10586)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist authored Jun 26, 2024
1 parent d7dc141 commit b1e1a4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ export const recordedProtocolMessagesCache = createFocusIntervalCacheForExecutio
return [];
}

const preferredLocation = getPreferredLocation(
sourcesState,
pointDescriptions[0].frame ?? []
);
const preferredLocation =
pointDescriptions[0].frame &&
getPreferredLocation(sourcesState, pointDescriptions[0].frame);

if (!preferredLocation) {
return [];
Expand Down
17 changes: 10 additions & 7 deletions src/ui/suspense/frameCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export interface FormattedPointStackFrame {
url?: string;
source: Source;
functionLocation: Location;
executionLocation: Location;
executionLocation?: Location;
point?: PointDescription;
functionDetails?: FormattedEventListener;
}
Expand Down Expand Up @@ -123,7 +123,8 @@ export const formattedPointStackCache: Cache<
const formattedFrames = pointStack.map(frame => {
updateMappedLocationForPointStackFrame(sourcesById, frame);
const functionLocation = getPreferredLocation(sourcesById, [], frame.functionLocation);
const executionLocation = getPreferredLocation(sourcesById, [], frame.point?.frame ?? []);
const executionLocation =
frame.point?.frame && getPreferredLocation(sourcesById, [], frame.point.frame);

const source = sourcesById.get(functionLocation.sourceId)!;

Expand Down Expand Up @@ -210,11 +211,13 @@ export const relevantAppFrameCache: Cache<
resultPoint = relevantAppCodeFrame.point;
}

const formattedFunction = await formatFunctionDetailsFromLocation(
replayClient,
"unknown",
relevantAppCodeFrame.executionLocation
);
const formattedFunction =
relevantAppCodeFrame.executionLocation &&
(await formatFunctionDetailsFromLocation(
replayClient,
"unknown",
relevantAppCodeFrame.executionLocation
));

functionName = formattedFunction?.functionName;
}
Expand Down
11 changes: 10 additions & 1 deletion src/ui/suspense/jumpToLocationCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export const reduxStoreDetailsCache = createSingleEntryCache<
function isFrameInDecl(functions: FunctionBoundaries[], frame: FormattedPointStackFrame) {
// Check to see if the frame is inside any of the listed function definitions
return functions.some(decl => {
if (!frame.executionLocation) {
return false;
}
return (
frame.executionLocation.line >= decl.location.begin.line &&
frame.executionLocation.line < decl.location.end.line &&
Expand Down Expand Up @@ -148,7 +151,13 @@ export function findFunctionParent(functions: FunctionOutline[], fnIndex: number
return null;
}

async function isReduxMiddleware(replayClient: ReplayClientInterface, location: Location) {
async function isReduxMiddleware(
replayClient: ReplayClientInterface,
location: Location | undefined
) {
if (!location) {
return false;
}
const sourceOutline = await sourceOutlineCache.readAsync(replayClient, location.sourceId);
const dispatchFn = findFunctionOutlineForLocation(location, sourceOutline);
const functions = sourceOutline.functions;
Expand Down

0 comments on commit b1e1a4c

Please sign in to comment.