fix(adapters): nest in-route spans under the navigation span (vue, svelte, next)#27
Merged
Conversation
The Vue Router integration cleared the route span in a separate beforeEach guard and only re-created it in afterEach, leaving a window where getRouteContext() was root. Clicks/fetch/errors fired in that gap — and intermittently the nav-link click that started the navigation — orphaned into their own root traces instead of nesting under the route span. Clear + re-create now happen atomically inside afterEach (matching the React adapter), so a route span is active at all times. - router.ts: drop the beforeEach clear; call clearRouteSpan() within afterEach - test: assert no beforeEach guard is registered + clear-before-set ordering - changeset: patch @tindalabs/blindspot-vue
The same route-span orphaning bug as the Vue adapter, found in two more integrations during an audit: - svelte: cleared the route span in beforeNavigate, re-created it in afterNavigate - next pages-router: cleared on routeChangeStart, re-created on routeChangeComplete Both left a window where getRouteContext() was root, so in-route clicks/fetch/ errors (and intermittently the navigation-triggering click) orphaned into their own root traces. The clear + re-create now happen atomically when the new route span is established, matching the React and Next app-router adapters (verified safe). The web base routing instrumentation was already atomic. - svelte/router.ts: drop beforeNavigate; clearRouteSpan() inside afterNavigate - next/pages-router.tsx: drop routeChangeStart; clearRouteSpan() in routeChangeComplete - tests: assert no separate clear guard + clear-before-set ordering - changeset: cover blindspot-vue / -svelte / -next (patch)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
In several framework adapters, in-route activity (clicks, fetch, errors, form submits) orphaned into its own root trace instead of nesting under the navigation span.
Root cause
Child spans parent to
getRouteContext(), valid only while a route span is set. The affected adapters cleared the route span in a step separate from re-creating it, leaving a window where the active context was root — any span started in that window (and intermittently the navigation-triggering click) became a standalone root trace.Audit (all routing integrations)
navigate-hookrouting.tsnavigate()beforeEach, set inafterEachbeforeNavigate, set inafterNavigaterouteChangeStart, set onrouteChangeCompleteFix
For vue/svelte/next-pages, do
clearRouteSpan()→ create →setRouteSpan()atomically when the new route span is established (afterEach/afterNavigate/routeChangeComplete). A route span is active at all times, so in-route activity nests — matching react / next app-router.Verification
click …/form.submitroot traces; post-fix they nest under the navigation span (confirmed in Grafana). The svelte and next-pages fixes are the identical pattern.clear-before-setordering. Tests pass: vue 16, svelte 17, next 14; builds + type-check + lint green.Patch changeset for
@tindalabs/blindspot-vue,-svelte,-next.