Skip to content

Commit b8bb51f

Browse files
Lms24claude
andcommitted
ref(core): Treat a null span end timestamp like a missing one
Use loose null checks when deciding whether to compute the span end time from the performance.now() duration, and move the misplaced _onSpanEnded doc comment back to its method. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent a3aecf6 commit b8bb51f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎packages/core/src/tracing/sentrySpan.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export class SentrySpan implements Span {
253253
return;
254254
}
255255

256-
this._endTime = endTimestamp === undefined ? this._getEndTimeFromDuration() : spanTimeInputToSeconds(endTimestamp);
256+
this._endTime = endTimestamp == null ? this._getEndTimeFromDuration() : spanTimeInputToSeconds(endTimestamp);
257257
logSpanEnd(this);
258258

259259
this._onSpanEnded();
@@ -359,21 +359,21 @@ export class SentrySpan implements Span {
359359
return !!this._isStandaloneSpan;
360360
}
361361

362-
/** Emit `spanEnd` when the span is ended. */
363362
/**
364363
* Returns the start time plus the `performance.now()` time since the span started.
365364
*
366365
* This way, the duration is correct even if the time origin was reset while the span was running (e.g. after the
367366
* device slept), and it can never be negative.
368367
*/
369368
private _getEndTimeFromDuration(): number {
370-
const performanceNow = this._startPerformanceNow === undefined ? undefined : safePerformanceNow();
371-
if (performanceNow === undefined || this._startPerformanceNow === undefined) {
369+
const performanceNow = this._startPerformanceNow == null ? undefined : safePerformanceNow();
370+
if (performanceNow == null || this._startPerformanceNow == null) {
372371
return timestampInSeconds();
373372
}
374373
return this._startTime + (performanceNow - this._startPerformanceNow) / 1000;
375374
}
376375

376+
/** Emit `spanEnd` when the span is ended. */
377377
private _onSpanEnded(): void {
378378
const client = getClient();
379379
client?.emit('spanEnd', this);

0 commit comments

Comments
 (0)