mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
add more detailed error handling if profiling data does not have any React marks (#22157)
Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
This commit is contained in:
co-authored by
Brian Vaughn
parent
0da5ad09db
commit
bd5bf555e1
+23
@@ -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({
|
||||
|
||||
+14
@@ -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.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user