@@ -715,4 +715,143 @@ describe('SchedulingProfiler', () => {
715715 ` ) ;
716716 }
717717 } ) ;
718+
719+ it ( 'should mark sync render that throws' , async ( ) => {
720+ class ErrorBoundary extends React . Component {
721+ state = { error : null } ;
722+ componentDidCatch ( error ) {
723+ this . setState ( { error} ) ;
724+ }
725+ render ( ) {
726+ if ( this . state . error ) {
727+ return null ;
728+ }
729+ return this . props . children ;
730+ }
731+ }
732+
733+ function ExampleThatThrows ( ) {
734+ throw Error ( 'Expected error' ) ;
735+ }
736+
737+ ReactTestRenderer . create (
738+ < ErrorBoundary >
739+ < ExampleThatThrows />
740+ </ ErrorBoundary > ,
741+ ) ;
742+
743+ if ( gate ( flags => flags . enableSchedulingProfiler ) ) {
744+ expect ( getMarks ( ) ) . toMatchInlineSnapshot ( `
745+ Array [
746+ "--schedule-render-1",
747+ "--render-start-1",
748+ "--component-render-start-ErrorBoundary",
749+ "--component-render-stop",
750+ "--component-render-start-ExampleThatThrows",
751+ "--component-render-start-ExampleThatThrows",
752+ "--component-render-stop",
753+ "--error-ExampleThatThrows-mount-Expected error",
754+ "--render-stop",
755+ "--commit-start-1",
756+ "--react-version-17.0.3",
757+ "--profiler-version-1",
758+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
759+ "--layout-effects-start-1",
760+ "--schedule-state-update-1-ErrorBoundary",
761+ "--layout-effects-stop",
762+ "--commit-stop",
763+ "--render-start-1",
764+ "--component-render-start-ErrorBoundary",
765+ "--component-render-stop",
766+ "--render-stop",
767+ "--commit-start-1",
768+ "--react-version-17.0.3",
769+ "--profiler-version-1",
770+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
771+ "--commit-stop",
772+ ]
773+ ` ) ;
774+ }
775+ } ) ;
776+
777+ it ( 'should mark concurrent render that throws' , async ( ) => {
778+ class ErrorBoundary extends React . Component {
779+ state = { error : null } ;
780+ componentDidCatch ( error ) {
781+ this . setState ( { error} ) ;
782+ }
783+ render ( ) {
784+ if ( this . state . error ) {
785+ return null ;
786+ }
787+ return this . props . children ;
788+ }
789+ }
790+
791+ function ExampleThatThrows ( ) {
792+ // eslint-disable-next-line no-throw-literal
793+ throw 'Expected error' ;
794+ }
795+
796+ ReactTestRenderer . create (
797+ < ErrorBoundary >
798+ < ExampleThatThrows />
799+ </ ErrorBoundary > ,
800+ { unstable_isConcurrent : true } ,
801+ ) ;
802+
803+ if ( gate ( flags => flags . enableSchedulingProfiler ) ) {
804+ expect ( getMarks ( ) ) . toMatchInlineSnapshot ( `
805+ Array [
806+ "--schedule-render-16",
807+ ]
808+ ` ) ;
809+ }
810+
811+ clearPendingMarks ( ) ;
812+
813+ expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
814+
815+ if ( gate ( flags => flags . enableSchedulingProfiler ) ) {
816+ if ( gate ( flags => flags . enableSchedulingProfiler ) ) {
817+ expect ( getMarks ( ) ) . toMatchInlineSnapshot ( `
818+ Array [
819+ "--render-start-16",
820+ "--component-render-start-ErrorBoundary",
821+ "--component-render-stop",
822+ "--component-render-start-ExampleThatThrows",
823+ "--component-render-start-ExampleThatThrows",
824+ "--component-render-stop",
825+ "--error-ExampleThatThrows-mount-Expected error",
826+ "--render-stop",
827+ "--render-start-16",
828+ "--component-render-start-ErrorBoundary",
829+ "--component-render-stop",
830+ "--component-render-start-ExampleThatThrows",
831+ "--component-render-start-ExampleThatThrows",
832+ "--component-render-stop",
833+ "--error-ExampleThatThrows-mount-Expected error",
834+ "--render-stop",
835+ "--commit-start-16",
836+ "--react-version-17.0.3",
837+ "--profiler-version-1",
838+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
839+ "--layout-effects-start-16",
840+ "--schedule-state-update-1-ErrorBoundary",
841+ "--layout-effects-stop",
842+ "--render-start-1",
843+ "--component-render-start-ErrorBoundary",
844+ "--component-render-stop",
845+ "--render-stop",
846+ "--commit-start-1",
847+ "--react-version-17.0.3",
848+ "--profiler-version-1",
849+ "--react-lane-labels-Sync,InputContinuousHydration,InputContinuous,DefaultHydration,Default,TransitionHydration,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Transition,Retry,Retry,Retry,Retry,Retry,SelectiveHydration,IdleHydration,Idle,Offscreen",
850+ "--commit-stop",
851+ "--commit-stop",
852+ ]
853+ ` ) ;
854+ }
855+ }
856+ } ) ;
718857} ) ;
0 commit comments