Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more detailed error handling if profiling data does not have any React marks #22157

Merged
merged 2 commits into from
Aug 23, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,29 @@ describe('preprocessData', () => {
await expect(async () => preprocessData([randomSample])).rejects.toThrow();
});

it('should throw given a timeline without an explicit profiler version mark nor any other React marks', async () => {
const cpuProfilerSample = creactCpuProfilerSample();

await expect(
async () => await preprocessData([cpuProfilerSample]),
).rejects.toThrow(
'Please provide profiling data from an React application',
);
});

it('should throw given a timeline with React scheduling marks, but without an explicit profiler version mark', async () => {
const cpuProfilerSample = creactCpuProfilerSample();
const scheduleRenderSample = createUserTimingEntry({
cat: 'blink.user_timing',
name: '--schedule-render-512-',
});
const samples = [cpuProfilerSample, scheduleRenderSample];

await expect(async () => await preprocessData(samples)).rejects.toThrow(
'This version of profiling data is not supported',
);
});

it('should return empty data given a timeline with no React scheduling profiling marks', async () => {
const cpuProfilerSample = creactCpuProfilerSample();
const randomSample = createUserTimingEntry({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,20 @@ export default async function preprocessData(
timeline.forEach(event => processTimelineEvent(event, profilerData, state));

if (profilerVersion === null) {
if (
profilerData.schedulingEvents.length === 0 &&
profilerData.batchUIDToMeasuresMap.size === 0
) {
// No profiler version could indicate data was logged using an older build of React,
// before an explicitly profiler version was included in the logging data.
// But it could also indicate that the website was either not using React, or using a production build.
// The easiest way to check for this case is to see if the data contains any scheduled updates or render work.
throw new InvalidProfileError(
'No React marks were found in the provided profile.' +
' Please provide profiling data from an React application running in development or profiling mode.',
);
}

throw new InvalidProfileError(
`This version of profiling data is not supported by the current profiler.`,
);
Expand Down