Skip to content

fix(adapters): nest in-route spans under the navigation span (vue, svelte, next)#27

Merged
Isonimus merged 2 commits into
mainfrom
fix/vue-route-span-nesting
Jun 8, 2026
Merged

fix(adapters): nest in-route spans under the navigation span (vue, svelte, next)#27
Isonimus merged 2 commits into
mainfrom
fix/vue-route-span-nesting

Conversation

@Isonimus

@Isonimus Isonimus commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

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)

Integration Before Verdict
react navigate-hook clear+create+set in one effect already safe (reference)
next app-router clear+create+set in one effect already safe
web base routing.ts atomic navigate() already safe
vue clear in beforeEach, set in afterEach fixed
svelte clear in beforeNavigate, set in afterNavigate fixed
next pages-router clear on routeChangeStart, set on routeChangeComplete fixed

Fix

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

  • Live (vue, docker stack + example): pre-fix Tempo showed standalone click … / form.submit root traces; post-fix they nest under the navigation span (confirmed in Grafana). The svelte and next-pages fixes are the identical pattern.
  • Unit: regression tests in all three packages assert no separate clear guard and clear-before-set ordering. Tests pass: vue 16, svelte 17, next 14; builds + type-check + lint green.

Patch changeset for @tindalabs/blindspot-vue, -svelte, -next.

Isonimus added 2 commits June 7, 2026 16:35
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)
@Isonimus Isonimus changed the title fix(vue): nest in-route spans under the navigation span fix(adapters): nest in-route spans under the navigation span (vue, svelte, next) Jun 8, 2026
@Isonimus Isonimus merged commit 2003457 into main Jun 8, 2026
3 checks passed
@Isonimus Isonimus deleted the fix/vue-route-span-nesting branch June 8, 2026 15:19
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.

1 participant