@@ -1624,18 +1624,25 @@ export function attach(
16241624 pendingOperations . push ( op ) ;
16251625 }
16261626
1627- function flushOrQueueOperations ( operations : OperationsArray ) : void {
1628- if ( operations . length === 3 ) {
1629- // This operations array is a no op: [renderer ID, root ID, string table size (0)]
1630- // We can usually skip sending updates like this across the bridge, unless we're Profiling.
1631- // In that case, even though the tree didn't change– some Fibers may have still rendered.
1632- if (
1633- ! isProfiling ||
1627+ function shouldBailoutWithPendingOperations ( ) {
1628+ if ( ! isProfiling ) {
1629+ return (
1630+ pendingOperations . length === 0 &&
1631+ pendingRealUnmountedIDs . length === 0 &&
1632+ pendingSimulatedUnmountedIDs . length === 0 &&
1633+ pendingUnmountedRootID === null
1634+ ) ;
1635+ } else {
1636+ return (
16341637 currentCommitProfilingMetadata == null ||
16351638 currentCommitProfilingMetadata . durations . length === 0
1636- ) {
1637- return ;
1638- }
1639+ ) ;
1640+ }
1641+ }
1642+
1643+ function flushOrQueueOperations ( operations : OperationsArray ) : void {
1644+ if ( shouldBailoutWithPendingOperations ( ) ) {
1645+ return ;
16391646 }
16401647
16411648 if ( pendingOperationsQueue !== null ) {
@@ -1668,7 +1675,7 @@ export function attach(
16681675
16691676 recordPendingErrorsAndWarnings ( ) ;
16701677
1671- if ( pendingOperations . length === 0 ) {
1678+ if ( shouldBailoutWithPendingOperations ( ) ) {
16721679 // No warnings or errors to flush; we can bail out early here too.
16731680 return ;
16741681 }
@@ -1791,12 +1798,7 @@ export function attach(
17911798 // We do this just before flushing, so we can ignore errors for no-longer-mounted Fibers.
17921799 recordPendingErrorsAndWarnings ( ) ;
17931800
1794- if (
1795- pendingOperations . length === 0 &&
1796- pendingRealUnmountedIDs . length === 0 &&
1797- pendingSimulatedUnmountedIDs . length === 0 &&
1798- pendingUnmountedRootID === null
1799- ) {
1801+ if ( shouldBailoutWithPendingOperations ( ) ) {
18001802 // If we aren't profiling, we can just bail out here.
18011803 // No use sending an empty update over the bridge.
18021804 //
@@ -1805,9 +1807,7 @@ export function attach(
18051807 // (2) the operations array for each commit
18061808 // Because of this, it's important that the operations and metadata arrays align,
18071809 // So it's important not to omit even empty operations while profiling is active.
1808- if ( ! isProfiling ) {
1809- return ;
1810- }
1810+ return ;
18111811 }
18121812
18131813 const numUnmountIDs =
@@ -2724,12 +2724,7 @@ export function attach(
27242724 }
27252725
27262726 if ( isProfiling && isProfilingSupported ) {
2727- // Make sure at least one Fiber performed work during this commit.
2728- // If not, don't send it to the frontend; showing an empty commit in the Profiler is confusing.
2729- if (
2730- currentCommitProfilingMetadata != null &&
2731- currentCommitProfilingMetadata . durations . length > 0
2732- ) {
2727+ if ( ! shouldBailoutWithPendingOperations ( ) ) {
27332728 const commitProfilingMetadata = ( ( rootToCommitProfilingMetadataMap : any ) : CommitProfilingMetadataMap ) . get (
27342729 currentRootID ,
27352730 ) ;
0 commit comments