fix(vue): Remove deprecated next callback from router instrumentation#19476
fix(vue): Remove deprecated next callback from router instrumentation#19476YevheniiKotyrlo wants to merge 1 commit intogetsentry:developfrom
Conversation
|
Thanks for the review. This concern does not apply here — the Vue Router version timeline:
Since Vue Router 4.0+ (the only router for Vue 3), guards with The |
Lms24
left a comment
There was a problem hiding this comment.
Hey @YevheniiKotyrlo thanks for opening the PR! Unfortunately, we still guarantee support for Vue 2 and Vue router 2 and 3. IIUC, this warning is shown on navigations for Vue router 5+? This isn't great so I understand why you want to see this fix.
Is there a way we can achieve fixing this without breaking anyone on older Vue router versions? I understand they're EOL but we can't just stop support within a major version of the SDK.
d111c2c to
83ad5c2
Compare
|
Good point — updated the PR to preserve Vue Router 2/3 backward compatibility. The root cause is that Vue Router's The fix uses two techniques:
This way Vue Router 3 users still get |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Summary
The Vue Router navigation guard registered by
instrumentVueRouterdeclares a thirdnextparameter, which triggers a deprecation warning in Vue Router 4.x+:Vue Router uses
Function.lengthto detect whether a guard expects the legacynextcallback. Since the guard declares 3 parameters (to,_from,next), Vue Router enters callback mode and emits the deprecation warning at runtime.This PR removes the
nextparameter entirely. Vue Router automatically resolves navigation for guards withlength < 3via its return-based pattern, so callingnext()was already a no-op in Vue Router 4+. Theif (next) { next(); }block was only needed for Vue Router 2/3 compatibility, which is no longer supported by@sentry/vuev8+.Relates to #8349
Changes
nextparameter from thebeforeEachguard ininstrumentVueRouterif (next) { next(); }compatibility blockVueRouterinterface to reflect the 2-parameter signaturemockNextusageFunction.lengthassertion that enforces the guard uses the modern return-based patternTest plan
Function.lengthassertion prevents future regressions