Skip to content

🐛 Stop retaining Angular views and errors queued before RUM starts - #5237

Merged
BeltranBulbarellaDD merged 4 commits into
mainfrom
beltran.bulbarella/address_angular_ssr
Nov 10, 2026
Merged

BeltranBulbarellaDD merged 4 commits into
mainfrom
beltran.bulbarella/address_angular_ssr

Conversation

@BeltranBulbarellaDD

@BeltranBulbarellaDD BeltranBulbarellaDD commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Addresses #5193. With provideDatadogRouter() or provideDatadogErrorHandler(), Angular SSR servers leak memory on every render.

Two causes:

  • Views and errors are queued in module-level subscriber arrays until RUM inits/starts. RUM never starts on the server, so these arrays grow forever.
  • Each queued view callback captures the whole route snapshot (root), which keeps the rendered app alive.

Changes

  • Replace the subscriber arrays with BufferedObservable, as the core pre-start buffer does, capped at the same 500 entries. Buffers are released on onInit / onRumStart.
  • Queue plain data instead of callbacks: views store only { name, url } (the name is computed when the navigation happens), errors store the addError payload.

Test instructions

  • yarn test:unit --spec 'packages/browser-rum-angular/**/*.spec.ts'
  • New provideDatadogRouter.spec.ts checks with a WeakRef + gc() that a route snapshot is collected when RUM isn't initialized. It fails without the fix. Karma's Chrome now runs with --js-flags=--expose-gc; the test is pending where gc() isn't available (BrowserStack).

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

…tore only view name instead of the whole root
@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 191.92 KiB 191.92 KiB 0 B 0.00% ✅
Rum 191.90 KiB 191.90 KiB 0 B 0.00% ✅
Rum Salesforce Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.04 KiB 32.04 KiB 0 B 0.00% ✅
Rum Recorder 32.04 KiB 32.04 KiB 0 B 0.00% ✅
Logs 60.11 KiB 60.11 KiB 0 B 0.00% ✅
Rum Slim 148.05 KiB 148.05 KiB 0 B 0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 222.35 KiB 222.35 KiB 0 B 0.00% ✅
Rum Shopify Profiler 8.35 KiB 8.35 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 85.71%
• Overall Coverage: 77.37% (+0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: dd040d3 | Docs | View more details | Give us feedback!

@BeltranBulbarellaDD BeltranBulbarellaDD changed the title Make Angular plugin use BufferedObservable for views and errors and s… 🐛 Stop retaining Angular views and errors queued before RUM starts Nov 4, 2026
@BeltranBulbarellaDD

Copy link
Copy Markdown
Contributor Author

@codex pls review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T10:37:16.030109Z dd040d3 New commits
🔒 Security Review ✅ Completed 2026-11-10T10:36:32.042866Z dd040d3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: e8b07df43a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: e8b07df43a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@BeltranBulbarellaDD
BeltranBulbarellaDD marked this pull request as ready for review November 5, 2026 14:15
@BeltranBulbarellaDD
BeltranBulbarellaDD requested a review from a team as a code owner November 5, 2026 14:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8b07df43a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@datadog-prod-us1-6 datadog-prod-us1-6 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: FAIL

Repeated pre-start initialization now causes duplicate view tracking. Error context getters can also throw outside monitoring and prevent Angular’s default error reporting.

Open Bits AI session

🤖 Bits Code Review · Commit e8b07df

- addAngularError: read dd_context inside callMonitored so a throwing getter
  can't escape the Angular error handler
- angularPlugin: unsubscribe the previous view observer when onInit runs again,
  so retried inits don't start each view several times

@rgaignault rgaignault left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like there is a missing file test, mentioned in the description ? provideDatadogRouter.spec.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd040d3c0b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@BeltranBulbarellaDD
BeltranBulbarellaDD merged commit 4303d6f into main Nov 10, 2026
31 checks passed
@BeltranBulbarellaDD
BeltranBulbarellaDD deleted the beltran.bulbarella/address_angular_ssr branch November 10, 2026 11:08
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants