Skip to content

Conversation

@thomas-lebeau
Copy link
Collaborator

@thomas-lebeau thomas-lebeau commented Jan 22, 2026

Motivation

This fixes a recurrent error in the sdk telemetry.

The error happens because currentElement.parentElement can actually be null, for example when the parent is a document fragment (in that case the parent is a Document, not an Element.)

Instead of relying on parent.firstElementChild to iterate siblings, the fix uses direct sibling traversal:

  • Check previousElementSibling (backward)
  • Check nextElementSibling (forward)

This approach works regardless of parent type, including when parentElement is null.

Changes

  • Replaced parent.firstElementChild iteration with direct previousElementSibling and nextElementSibling traversal
  • Added tests for DocumentFragment scenarios with matching and non-matching siblings

Test instructions

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@thomas-lebeau thomas-lebeau marked this pull request as ready for review January 22, 2026 16:06
@thomas-lebeau thomas-lebeau requested a review from a team as a code owner January 22, 2026 16:06
@thomas-lebeau thomas-lebeau changed the title 🐛 Fix sibling uniqueness check for elements in DocumentFragment 🐛 RUM-13741 Fix sibling uniqueness check for elements in DocumentFragment Jan 23, 2026
@thomas-lebeau thomas-lebeau changed the title 🐛 RUM-13741 Fix sibling uniqueness check for elements in DocumentFragment 🐛 [RUM-13741] Fix sibling uniqueness check for elements in DocumentFragment Jan 23, 2026
@thomas-lebeau thomas-lebeau force-pushed the thomas.lebeau/fix-null-is-not-an-object branch from 43b8e70 to bcfaee6 Compare January 23, 2026 08:27
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Jan 23, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 71.43%
Overall Coverage: 77.25% (-0.08%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: bcfaee6 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Jan 23, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 165.78 KiB 165.84 KiB +59 B +0.03%
Rum Profiler 4.33 KiB 4.33 KiB 0 B 0.00%
Rum Recorder 24.48 KiB 24.48 KiB 0 B 0.00%
Logs 56.21 KiB 56.21 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 123.05 KiB 123.11 KiB +59 B +0.05%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0039 0.0047 +20.51%
RUM - add action 0.0129 0.014 +8.53%
RUM - add error 0.0123 0.0154 +25.20%
RUM - add timing 0.0025 0.0031 +24.00%
RUM - start view 0.003 0.0039 +30.00%
RUM - start/stop session replay recording 0.0006 0.0008 +33.33%
Logs - log message 0.0143 0.0161 +12.59%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 27.89 KiB 26.26 KiB -1.62 KiB
RUM - add action 50.08 KiB 49.98 KiB -104 B
RUM - add timing 27.36 KiB 26.99 KiB -385 B
RUM - add error 55.79 KiB 56.09 KiB +304 B
RUM - start/stop session replay recording 24.97 KiB 25.11 KiB +147 B
RUM - start view 427.11 KiB 426.77 KiB -347 B
Logs - log message 45.38 KiB 98.59 KiB +53.22 KiB

🔗 RealWorld

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.

2 participants