fix(web): make performance timing non-blocking
Fixes SOU-2250
Summary
- calculate timing durations with performance.now() instead of relying on the return value of performance.measure()
- preserve existing performance marks and named measures for browser debugging
- isolate optional Performance Timeline failures from the measured application behavior
- add regression coverage for undefined measure results and instrumentation failures
Test plan
- yarn workspace @sourcebot/web test src/lib/utils.test.ts src/ee/features/codeNav/components/symbolHoverPopup/symbolHoverTargetsExtension.test.ts
- yarn workspace @sourcebot/web exec eslint src/lib/utils.ts src/lib/utils.test.ts
- focused TypeScript check for the changed files
[!NOTE]
Low Risk
Client-side defensive change to shared timing helpers; behavior for successful paths is equivalent aside from duration source, with no security or data-handling impact.
Overview
Fixes code view breakage when browser Performance Timeline APIs misbehave (e.g. performance.measure() returning no value).
measure / measureSync in packages/web/src/lib/utils.ts now derive durationMs from performance.now() before and after the callback instead of reading measure.duration. Marks and named measures are still recorded for DevTools via new recordPerformanceMark / recordPerformanceMeasure helpers that swallow mark/measure errors so instrumentation cannot throw into callers (including code nav symbol hover and file browsing).
Adds packages/web/src/lib/utils.test.ts covering undefined measure results and thrown timeline APIs. Documents the fix under Unreleased → Fixed in CHANGELOG.md.
Reviewed by Cursor Bugbot for commit 68d7cd2f820763f6e34561fd8b06319fd6ddb395. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Fixes SOU-2250 by making browser performance timing non-blocking. measure and measureSync previously depended on performance.measure()'s return value; they now use performance.now() deltas, while ignoring Performance Timeline failures so instrumentation cannot break code views or measured operations. Existing marks and named measures remain available for DevTools.
Coverage
- Adds sync and async regression tests for missing measure results and thrown mark/measure calls.
- Documents the fix in the changelog.
Summary by CodeRabbit
-
Bug Fixes
- Browser performance instrumentation no longer interrupts code views or measured operations when performance measurements are unavailable or fail.
- Performance durations are now calculated reliably using timestamps.
-
Tests
- Added coverage for synchronous and asynchronous performance measurement, including instrumentation failures and missing measurement results.
-
Documentation
- Updated the unreleased changelog with the performance instrumentation fix.