@@ -1995,7 +1995,7 @@ function visitAsyncNode(
1995
1995
owner : node . owner ,
1996
1996
stack : stack ,
1997
1997
} ) ;
1998
- advanceTaskTime ( request , task , endTime ) ;
1998
+ markOperationEndTime ( request , task , endTime ) ;
1999
1999
}
2000
2000
}
2001
2001
}
@@ -2035,7 +2035,7 @@ function emitAsyncSequence(
2035
2035
awaited : ( ( awaitedNode : any ) : ReactIOInfo ) , // This is deduped by this reference.
2036
2036
env : env ,
2037
2037
} ) ;
2038
- advanceTaskTime ( request , task , awaitedNode . end ) ;
2038
+ markOperationEndTime ( request , task , awaitedNode . end ) ;
2039
2039
}
2040
2040
}
2041
2041
@@ -4255,7 +4255,7 @@ function forwardDebugInfo(
4255
4255
// When forwarding time we need to ensure to convert it to the time space of the payload.
4256
4256
// We clamp the time to the starting render of the current component. It's as if it took
4257
4257
// no time to render and await if we reuse cached content.
4258
- advanceTaskTime ( request , task , info . time ) ;
4258
+ markOperationEndTime ( request , task , info . time ) ;
4259
4259
} else {
4260
4260
if ( typeof info . name === 'string' ) {
4261
4261
// We outline this model eagerly so that we can refer to by reference as an owner.
@@ -4352,6 +4352,20 @@ function advanceTaskTime(
4352
4352
task . timed = true ;
4353
4353
}
4354
4354
4355
+ function markOperationEndTime ( request : Request , task : Task , timestamp : number ) {
4356
+ if ( ! enableProfilerTimer || ! enableComponentPerformanceTrack ) {
4357
+ return ;
4358
+ }
4359
+ // This is like advanceTaskTime() but always emits a timing chunk even if it doesn't advance.
4360
+ // This ensures that the end time of the previous entry isn't implied to be the start of the next one.
4361
+ if ( timestamp > task . time ) {
4362
+ emitTimingChunk ( request , task . id , timestamp ) ;
4363
+ task . time = timestamp ;
4364
+ } else {
4365
+ emitTimingChunk ( request , task . id , task . time ) ;
4366
+ }
4367
+ }
4368
+
4355
4369
function emitChunk (
4356
4370
request : Request ,
4357
4371
task : Task ,
@@ -4443,7 +4457,7 @@ function emitChunk(
4443
4457
function erroredTask ( request : Request , task : Task , error : mixed ) : void {
4444
4458
if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
4445
4459
if ( task . timed ) {
4446
- advanceTaskTime ( request , task , performance . now ( ) ) ;
4460
+ markOperationEndTime ( request , task , performance . now ( ) ) ;
4447
4461
}
4448
4462
}
4449
4463
task . status = ERRORED ;
@@ -4526,7 +4540,7 @@ function retryTask(request: Request, task: Task): void {
4526
4540
// We've finished rendering. Log the end time.
4527
4541
if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
4528
4542
if ( task . timed ) {
4529
- advanceTaskTime ( request , task , performance . now ( ) ) ;
4543
+ markOperationEndTime ( request , task , performance . now ( ) ) ;
4530
4544
}
4531
4545
}
4532
4546
@@ -4653,7 +4667,7 @@ function abortTask(task: Task, request: Request, errorId: number): void {
4653
4667
// Track when we aborted this task as its end time.
4654
4668
if ( enableProfilerTimer && enableComponentPerformanceTrack ) {
4655
4669
if ( task . timed ) {
4656
- advanceTaskTime ( request , task , performance . now ( ) ) ;
4670
+ markOperationEndTime ( request , task , performance . now ( ) ) ;
4657
4671
}
4658
4672
}
4659
4673
// Instead of emitting an error per task.id, we emit a model that only
0 commit comments