Skip to content

fix(trace-utils): format timestamps with hours when trace duration ex…#41268

Open
Git-Raini wants to merge 1 commit into
microsoft:mainfrom
Git-Raini:fix/40068-trace-timeline-hours
Open

fix(trace-utils): format timestamps with hours when trace duration ex…#41268
Git-Raini wants to merge 1 commit into
microsoft:mainfrom
Git-Raini:fix/40068-trace-timeline-hours

Conversation

@Git-Raini

@Git-Raini Git-Raini commented Jun 12, 2026

Copy link
Copy Markdown

fix: format timestamps with hours when trace duration exceeds 60 minutes

Summary

Fixes #40068 — Trace timeline displays incorrect time format when test or fixture duration exceeds 60 minutes.

Problem

When a trace session lasts longer than 60 minutes (e.g. an APIRequestContext fixture that runs for hours), the trace viewer's CLI timeline shows:

120:00.000

instead of:

2:00:00.000

This is confusing and makes it difficult to read long-running test traces.

Root Cause

formatTimestamp(ms, base) in packages/playwright-core/src/tools/trace/traceUtils.ts only formats up to minutes:seconds.millis. Durations ≥ 60 min overflow into raw minute counts.

Solution

Updated formatTimestamp to:

  • Compute hours from the total seconds
  • Prefix H:MM:SS.mmm when hours > 0
  • Keep the existing M:SS.mmm format for sub-hour traces (backward-compatible)

Files Changed

  • packages/playwright-core/src/tools/trace/traceUtils.ts — 10 insertions(+), 3 deletions(-)

Benefits

  • Long-running tests/traces now display correctly in the CLI trace viewer
  • No behavior change for traces under 1 hour
  • Zero additional dependencies

…ceeds 60 minutes

Previously, formatTimestamp capped at minutes, producing '120:00.000'
for traces lasting two hours. This change adds hour-level formatting so
long-running traces render correctly as '2:00:00.000'.

Fixes microsoft#40068
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Trace timeline Showing Hours when using APIRequestContext in fixture

1 participant