designcourse icon indicating copy to clipboard operation
designcourse copied to clipboard

🐛 do not calculate resource duration if page was in frozen state during resource duration

Open thomas-lebeau opened this issue 9 months ago • 2 comments

Motivation

Fixes Bug with resource duration where incorrect due to page being in a frozen state sometime during the request.

The intention was to set duration to undefined when the page was in a frozen state during the request duration (computeRequestDuration), however this was overridden by computeResourceEntryMetrics.

The unit tests where not catching the issue because no matching PerformanceResourceTiming was mocked.

Changes

  • Mock a matching PerformanceResourceTiming, making the unit test fail.
  • Make computeResourceEntryMetrics aware of frozen states and prevent calculating any durations when needed.
  • Improve fetch and XHR request collection unit test to take into account a matching PerformanceResourceTiming.

Testing

  • [x] Local
  • [ ] Staging
  • [x] Unit
  • [ ] End to end

I have gone over the contributing documentation.

thomas-lebeau avatar Feb 18 '25 14:02 thomas-lebeau

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.84%. Comparing base (200982d) to head (c8059f8). Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...rum-core/src/domain/resource/resourceCollection.ts 91.66% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3349      +/-   ##
==========================================
- Coverage   92.86%   92.84%   -0.03%     
==========================================
  Files         298      298              
  Lines        7845     7850       +5     
  Branches     1785     1787       +2     
==========================================
+ Hits         7285     7288       +3     
- Misses        560      562       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Feb 18 '25 14:02 codecov-commenter

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 147.64 KiB 147.74 KiB 104 B +0.07%
Logs 51.65 KiB 51.65 KiB 0 B 0.00%
Rum Slim 106.34 KiB 106.44 KiB 97 B +0.09%
Worker 24.50 KiB 24.50 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.002 0.002 -0.001
addaction 0.073 0.055 -0.018
addtiming 0.002 0.001 -0.000
adderror 0.104 0.053 -0.051
startstopsessionreplayrecording 0.014 0.012 -0.002
startview 0.522 0.412 -0.110
logmessage 0.035 0.023 -0.011
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 28.88 KiB 31.26 KiB 2.38 KiB
addaction 57.28 KiB 57.76 KiB 488 B
addtiming 27.22 KiB 29.55 KiB 2.33 KiB
adderror 59.49 KiB 64.67 KiB 5.18 KiB
startstopsessionreplayrecording 25.91 KiB 27.71 KiB 1.80 KiB
startview 423.80 KiB 427.08 KiB 3.28 KiB
logmessage 64.10 KiB 61.96 KiB -2198 B

🔗 RealWorld

cit-pr-commenter[bot] avatar Feb 18 '25 15:02 cit-pr-commenter[bot]