Throw the User Timing spec's errors from mark() and measure() #8849
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 235 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.327
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8849"
general
weight: 0.35
littledivy
performance.mark(), thePerformanceMarkconstructor andperformance.measure()accept arguments the User Timing spec rejects. A negativestartTime,startorendis kept as is.measure()takes an options object together with an end mark, options with neitherstartnorend, and options with all ofstart,endandduration. A mark name that doesn't exist quietly measures from 0 or to the current time, andnavigationStartand the other PerformanceTiming names are looked up as ordinary marks. Browsers and Node.js throw a TypeError or a SyntaxError for each of these.In this patch the constructor rejects a negative
startTime, andmark()now builds its entry through the constructor, so both get that check.measure()follows the spec steps: the option combinations above and a negativestart,endordurationthrow a TypeError, a PerformanceTiming attribute name throws a TypeError even when a mark with that name exists (a Worker isn't a Window), and any other name with no mark throws a SyntaxError DOMException. Options withendanddurationbut nostartnow start the measure atend - durationinstead of 0.{},nullandundefinedas the second argument still mean no options.There is no compat flag. These calls work today and will start throwing, but Workers use User Timing mostly for code that also runs in browsers and Node.js, which already throw these errors, so code is more likely to expect them than to rely on the quiet fallback.
perf-hooks-nodejs-test gets a case for each error. They call
performance.markbound, because the WPT mark-errors test calls it unbound and so passes from the "Illegal invocation" TypeError alone. The expected failures in mark-errors, measure-with-dict, measure_syntax_err and performance-measure-invalid.worker are removed. The new tests and those WPT cases fail without the fix.