Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [RUM-6411] RUM should not crash with puppeteer injection #3153

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

cy-moi
Copy link
Contributor

@cy-moi cy-moi commented Nov 20, 2024

Motivation

RUM would crash when injected with puppeteer evaluateOnNewDocument because resizeObserver is observing on non-document targets.

Changes

Add check for observe target
Add e2e test for inject rum with puppeteer

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@codecov-commenter
Copy link

codecov-commenter commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.45%. Comparing base (82d898a) to head (9f78ec5).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3153      +/-   ##
==========================================
+ Coverage   93.43%   93.45%   +0.01%     
==========================================
  Files         280      280              
  Lines        7679     7680       +1     
  Branches     1719     1720       +1     
==========================================
+ Hits         7175     7177       +2     
+ Misses        504      503       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@cy-moi cy-moi marked this pull request as ready for review November 20, 2024 16:47
@cy-moi cy-moi requested a review from a team as a code owner November 20, 2024 16:47
Copy link

cit-pr-commenter bot commented Nov 20, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.60 KiB 161.60 KiB 3 B 0.00%
Logs 55.85 KiB 55.85 KiB 0 B 0.00%
Rum Slim 110.44 KiB 110.44 KiB 3 B 0.00%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.001 0.002 0.001
addaction 0.031 0.060 0.029
addtiming 0.001 0.002 0.001
adderror 0.032 0.040 0.008
startstopsessionreplayrecording 0.809 1.074 0.264
startview 1.020 1.327 0.308
logmessage 0.019 0.023 0.004
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 8.98 KiB 7.59 KiB -1423 B
addaction 41.07 KiB 39.66 KiB -1441 B
addtiming 6.30 KiB 6.50 KiB 205 B
adderror 44.70 KiB 44.09 KiB -622 B
startstopsessionreplayrecording 5.15 KiB 5.70 KiB 564 B
startview 421.72 KiB 426.63 KiB 4.91 KiB
logmessage 40.13 KiB 40.09 KiB -39 B

🔗 RealWorld

@@ -102,7 +102,9 @@ export function createScrollValuesObservable(

const observerTarget = document.scrollingElement || document.documentElement
const resizeObserver = new ResizeObserver(monitor(throttledNotify.throttled))
resizeObserver.observe(observerTarget)
if (observerTarget instanceof Element) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion:

Suggested change
if (observerTarget instanceof Element) {
if (observerTarget) {

@@ -228,3 +230,33 @@ async function tearDownTest({ intakeRegistry }: TestContext) {
})
await deleteAllCookies()
}

export async function injectRumWithPuppeteer() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 suggestion: ‏Move this function out of this module as it has little to do with the createTest helper. Since it is only one test case, you could even inline the code inside of the test

@cy-moi cy-moi force-pushed the congyao/RUM-6411-e2e-test-with-puppeteer branch from 15e724f to ef5afb3 Compare November 25, 2024 13:08
@cy-moi cy-moi force-pushed the congyao/RUM-6411-e2e-test-with-puppeteer branch from ef5afb3 to 9f78ec5 Compare November 25, 2024 13:16
@cy-moi cy-moi merged commit c60a856 into main Nov 25, 2024
19 checks passed
@cy-moi cy-moi deleted the congyao/RUM-6411-e2e-test-with-puppeteer branch November 25, 2024 16:29
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.

4 participants