Uh oh!
There was an error while loading. Please reload this page.
fix(trace): record failed request durations, print request start times - #42191
Conversation
Failure is the only HAR entry finish path that computes no timings, so failed and route.abort()ed requests kept `time` at its -1 default and traces never recorded when such requests ended. Derive the duration from the entry's monotonic start timestamp instead. Gated on the trace-only `_monotonicTime` field, so user-exported HAR files are unaffected and keep the spec-defined value. With this, every request in a trace has a complete lifetime, and `trace requests` prints a real duration where it previously showed '-'.
`trace actions` prints each action's relative start time, but `trace requests` printed only durations, so whether a request was still in flight when an action ran was not derivable from CLI output. Print each request's start from `_monotonicTime`, which the trace model adjusts by the same clock delta as action times, using the same timestamp format as the actions Time column so the two tables correlate directly. The `request <id>` detail view gains a matching `start:` line.
Pavel Feldman (pavelfeldman)
left a comment
There was a problem hiding this comment.
Looks good, those are just nit picks
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
John Hill (unlikelyzero)
commented
Aug 11, 2026
Pavel Feldman (@pavelfeldman) addressed! |
There was a problem hiding this comment.
Pull request overview
Improves Playwright trace tooling by making network request timing comparable to action timing in CLI output, and by ensuring failed/aborted requests have a recorded duration in trace HAR data (trace-only fields).
Changes:
- Record
harEntry.timefor failed/aborted requests when trace-only_monotonicTimeis present. - Add request start timestamps to
trace requestsandtrace request <id>output. - Extend MCP and tracing tests to cover request start/duration behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/mcp/trace-cli.spec.ts | Adds assertions for request start timestamps and aborted request durations in trace CLI output. |
| tests/mcp/trace-cli-fixtures.ts | Introduces an aborted request scenario to exercise trace request timing output. |
| tests/library/tracing.spec.ts | Adds trace-level assertions that failures include _monotonicTime and a non-negative duration. |
| packages/playwright-core/src/tools/trace/traceRequests.ts | Prints request start timestamps in list/detail views using the trace action clock. |
| packages/playwright-core/src/tools/skills/playwright-trace/SKILL.md | Updates CLI skill docs to mention request start time output. |
| packages/playwright-core/src/server/har/harTracer.ts | Computes harEntry.time on request failure when trace-only monotonic timestamps exist. |
Suppressed comments (1)
packages/playwright-core/src/tools/trace/traceRequests.ts:99
- Same truthy check issue as above: if
_monotonicTimeis 0, thestart:line will be omitted even though the timestamp is known.
if (r._monotonicTime)
console.log(` start: ${formatTimestamp(r._monotonicTime, model.startTime)}`);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Test results for "tests 1"6 flaky51042 passed, 1190 skipped Merge workflow run. |
Test results for "MCP"1 failed 8091 passed, 1294 skipped Merge workflow run. |
5d21e76
into
microsoft:mainUh oh!
There was an error while loading. Please reload this page.
Summary
route.abort()ed requests when tracing — the failure path previously left HARtimeat-1, so traces never knew when such requests ended. Gated on the trace-only_monotonicTimefield; user-exported HAR files are unaffected.Startcolumn totrace requests(same clock and format as thetrace actionsTime column) and astart:line totrace request <id>, so request/action overlap is readable directly from CLI output.Fixes#42172