File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
packages/react-devtools-scheduling-profiler/src/import-worker Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,29 @@ describe('preprocessData', () => {
234234 await expect ( async ( ) => preprocessData ( [ randomSample ] ) ) . rejects . toThrow ( ) ;
235235 } ) ;
236236
237+ it ( 'should throw given a timeline without an explicit profiler version mark nor any other React marks' , async ( ) => {
238+ const cpuProfilerSample = creactCpuProfilerSample ( ) ;
239+
240+ await expect (
241+ async ( ) => await preprocessData ( [ cpuProfilerSample ] ) ,
242+ ) . rejects . toThrow (
243+ 'Please provide profiling data from an React application' ,
244+ ) ;
245+ } ) ;
246+
247+ it ( 'should throw given a timeline with React scheduling marks, but without an explicit profiler version mark' , async ( ) => {
248+ const cpuProfilerSample = creactCpuProfilerSample ( ) ;
249+ const scheduleRenderSample = createUserTimingEntry ( {
250+ cat : 'blink.user_timing' ,
251+ name : '--schedule-render-512-' ,
252+ } ) ;
253+ const samples = [ cpuProfilerSample , scheduleRenderSample ] ;
254+
255+ await expect ( async ( ) => await preprocessData ( samples ) ) . rejects . toThrow (
256+ 'This version of profiling data is not supported' ,
257+ ) ;
258+ } ) ;
259+
237260 it ( 'should return empty data given a timeline with no React scheduling profiling marks' , async ( ) => {
238261 const cpuProfilerSample = creactCpuProfilerSample ( ) ;
239262 const randomSample = createUserTimingEntry ( {
Original file line number Diff line number Diff line change @@ -912,6 +912,20 @@ export default async function preprocessData(
912912 timeline . forEach ( event => processTimelineEvent ( event , profilerData , state ) ) ;
913913
914914 if ( profilerVersion === null ) {
915+ if (
916+ profilerData . schedulingEvents . length === 0 &&
917+ profilerData . batchUIDToMeasuresMap . size === 0
918+ ) {
919+ // No profiler version could indicate data was logged using an older build of React,
920+ // before an explicitly profiler version was included in the logging data.
921+ // But it could also indicate that the website was either not using React, or using a production build.
922+ // The easiest way to check for this case is to see if the data contains any scheduled updates or render work.
923+ throw new InvalidProfileError (
924+ 'No React marks were found in the provided profile.' +
925+ ' Please provide profiling data from an React application running in development or profiling mode.' ,
926+ ) ;
927+ }
928+
915929 throw new InvalidProfileError (
916930 `This version of profiling data is not supported by the current profiler.` ,
917931 ) ;
You can’t perform that action at this time.
0 commit comments