Repository navigation
🐛 [RUM-19914] Stop retaining Vue views and errors queued before RUM starts - #5280
Conversation
Bundles Sizes Evolution
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 1468ce7 | Docs | View more details | Give us feedback! |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ec49350e0
ℹ️ 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".
There was a problem hiding this comment.
The most critical issue is a race condition in vuePlugin.ts where retrying initialization before microtasks drain causes buffered view names to be dropped, potentially leaving RUM unstarted when router: true is set. Separately, addVueError.ts captures the handling stack inside callMonitored rather than before it, producing incorrect stack frames for Vue error diagnostics.
🤖 Bits Code Review · Commit 7ec4935
| expect(startView).toHaveBeenCalledOnceWith('/a') | ||
| }) | ||
|
|
||
| it('starts each view once when onInit is called several times', async () => { |
There was a problem hiding this comment.
suggestion
if we remove viewSubscription?.unsubscribe() line from vuePlugin this test will still pass
let's assign first initPlugin call to a variable as well and check that
expect(firstStartView).not.toHaveBeenCalled()
…onInit refs: RUM-19914 Keep the first onInit's startView spy and check it is never called, so the test fails if the previous subscription is not unsubscribed.
Motivation
The Vue plugin queued callbacks in unbounded module-level arrays until RUM initialized or started. During server-side rendering RUM never starts, so every navigation (closure over
to.matched, route records holding components) and every reported error (closure over the component instance) was retained forever. This is the Vue counterpart of the Angular fix in #5237 (issue #5193).Jira: RUM-19914
Changes
vuePluginbuffers plain data in aBufferedObservablecapped at 500 (like the core pre-start buffer): view names and fully built error payloads. Buffered items are replayed in order ononInit/onRumStart; repeatedonInitkeeps a single view subscriber.addVueErrorbuilds the whole payload (handling stack, clocks, component stack,dd_context) eagerly insidecallMonitored, so the component instance is not kept.onRumInit/onRumStarthelpers are removed (not exported). Public API, view names, error payloads and therouter: truewarning are unchanged. Replay now happens one microtask after init, as in the Angular plugin.Test instructions
yarn test:unit packages/browser-rum-vue: new specs cover replay order, delivery after init, single delivery on repeated init, the router warning, the 500 cap for views and errors, and a throwingdd_contextgetter (43/43 pass locally).yarn typecheck, eslint and prettier pass locally.test/apps/vue-router-app, delaydatadogRum.init500 ms after mount, a navigation to/user/42and anaddVueErrorcall, collect events withbeforeSend. After init, the/view, thepre-init errorerror and the/user/:idview are received.gc()spec (Chromium with--expose-gc, no app mounted): route record and component instance were retained before the fix and collected after. That spec is not included.Checklist