feat(astro): Implement Request Route Parametrization for Astro 5#17105
feat(astro): Implement Request Route Parametrization for Astro 5#17105
Conversation
72df08c to
5e48038
Compare
Lms24
left a comment
There was a problem hiding this comment.
Just a few questions -- nice work!
| // Server HTTP request transaction - should be parametrized (todo: currently not parametrized) | ||
| expect(serverHTTPServerRequestTxn).toMatchObject({ | ||
| transaction: 'GET /api/user/myUsername123.json', // todo: should be parametrized to 'GET /api/user/[userId].json' | ||
| transaction: 'GET /api/user/[userId].json', |
There was a problem hiding this comment.
l: Is there a test that ensures that a known route like GET / api/user/settings.json? Just wanna make sure we can disambiguate these routes :)
There was a problem hiding this comment.
not yet, but I was thinking about that!
In this case, it would work as user/settings and user/someID can be differentiated easily by matching the routePattern. routePattern will be user/settings or user/[userid] (all lowercased).
| const interpolatedRoute = | ||
| foundRoute?.patternCaseSensitive || interpolateRouteFromUrlAndParams(ctx.url.pathname, ctx.params); |
There was a problem hiding this comment.
also just so that I understand correctly: The ctx.routePattern alone is case-insensitive and we use the build time-injected information so that we get the case-sensitive one?
Lms24
left a comment
There was a problem hiding this comment.
Thanks for clarifying!
(I'll leave reviewing the cursor stuff up to you. Pretty sure some of the findings don't apply).
|
Addressing cursor comments:
That's no problem during build-time as the hook is only called once. During runtime I'll add a variable to make sure it only runs once.
That's why I am appending
No because the
No, only Astro version lower than 5 |
There was a problem hiding this comment.
Bug: Sentry Route Info Repeatedly Appended
The astro:routes:resolved hook unconditionally appends globalThis["__sentryRouteInfo"] to the user's server init file. The didSaveRouteData flag only prevents multiple writes within a single build process, causing route information to be repeatedly appended across multiple builds. This leads to file bloat, duplicate assignments, and potential JavaScript syntax errors or unexpected runtime behavior.
packages/astro/src/integration/index.ts#L174-L203
sentry-javascript/packages/astro/src/integration/index.ts
Lines 174 to 203 in b4ec0f7
Was this report helpful? Give feedback by reacting with 👍 or 👎
) Route Parametrization for Server Requests in Astro 5. The route information is gathered during build-time. During runtime, the route information is matched to use the parametrized route information during runtime Part of #16686
Route Parametrization for Server Requests in Astro 5.
The route information is gathered during build-time. During runtime, the route information is matched to use the parametrized route information during runtime
Part of #16686