Skip to content

feat(sveltekit): Add option to control handling of unknown server routes#8201

Merged
Lms24 merged 2 commits intodevelopfrom
lms/sveltekit-fix-server-trace-invalid-routes
May 30, 2023
Merged

feat(sveltekit): Add option to control handling of unknown server routes#8201
Lms24 merged 2 commits intodevelopfrom
lms/sveltekit-fix-server-trace-invalid-routes

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented May 24, 2023

This PR adds a handleUnknownRoutes option to the sentryHandle server request handler. The option defaults to false which would effectively reduce noise, such as random bot requests. Previously such requests would yield e.g. GET null transactions because they could not be matched to an existing route by the framework. See #8199

Note: Users can right now also drop these transactions in ignoreTransactions or beforeSendTransaction but I think we should pre-filter them by default but give them the option to still monitor such requests if they choose to do so.:

Example:

Users register a custom handler (or a handler from a library)

// hooks.server.js

export const handler = sequence(
  sentryHandle(),
  async ({event, resolve}) => {
    if (event.url.pathname.startsWith('/ext-api/auth') { // <-- this endpoint does not exist as a route
      return await getResponseFromExternalAuthService(event.request);
    }
    return resolve(event) 
  }
)

which "understands" requests that are not mapped to a SvelteKit route. This request would not lead to a transaction, unless handleUnknownRoutes was set to true.

resolves #8199

Loading
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.

SvelteKit SDK creates server transactions with [Method] null name

2 participants