Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix regression
  • Loading branch information
chargome committed Mar 18, 2026
commit 14d7349386772900a5878e023c16c61a975e5a86
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function isTunnelRouteSpan(spanAttributes: Record<string, unknown>): boolean {
// Extract pathname from the target (e.g., "/tunnel?o=123&p=456" -> "/tunnel")
const pathname = httpTarget.split('?')[0] || '';

return pathname.startsWith(tunnelPath);
return pathname === tunnelPath || pathname.startsWith(`${tunnelPath}/`);
}

return false;
Expand Down
12 changes: 12 additions & 0 deletions packages/nextjs/test/utils/dropMiddlewareTunnelRequests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
expect(span.setAttribute).not.toHaveBeenCalled();
});

it('does not mark BaseServer.handleRequest span for dropping when http.target shares tunnel path prefix', () => {
globalWithInjectedValues._sentryRewritesTunnelPath = '/monitoring';
const span = createMockSpan();

dropMiddlewareTunnelRequests(span as any, {
'next.span_type': 'BaseServer.handleRequest',
'http.target': '/monitoring-dashboard',
});

expect(span.setAttribute).not.toHaveBeenCalled();
});

it('does not mark BaseServer.handleRequest span when no tunnel path is configured', () => {
const span = createMockSpan();

Expand Down Expand Up @@ -126,7 +138,7 @@
describe('skipOpenTelemetrySetup', () => {
it('does not process spans when skipOpenTelemetrySetup is true', async () => {
const core = await import('@sentry/core');
const originalGetClient = core.getClient;

Check warning on line 141 in packages/nextjs/test/utils/dropMiddlewareTunnelRequests.test.ts

View workflow job for this annotation

GitHub Actions / Lint

eslint(no-unused-vars)

Variable 'originalGetClient' is declared but never used. Unused variables should start with a '_'.
vi.spyOn(core, 'getClient').mockReturnValueOnce({
getOptions: () => ({ skipOpenTelemetrySetup: true }),
} as any);
Expand Down
Loading