Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(astro): Only track access request headers in dynamic page requests #13306

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Aug 12, 2024

This PR fixes a bug in the Astro SDK which would emerge if users configured their app as SSR output hybrid or server but also had static routes.

In Astro middleware, we're not allowed to access the request.headers object if the incoming request is for a statically generated/prerendered route. Since we accessed these headers previously, users would get a warning as reported multiple times and tracked in #13116

fixes #13116

Note: While working on this, I discovered another bug which I'll fix in a follow-up PR. Also, I'll finally add an e2e test app.

@Lms24 Lms24 requested review from mydea and s1gr1d August 12, 2024 11:20
@Lms24 Lms24 self-assigned this Aug 12, 2024
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser 22.47 KB (0%)
@sentry/browser (incl. Tracing) 34.26 KB (0%)
@sentry/browser (incl. Tracing, Replay) 70.32 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.65 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 74.71 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 87.33 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 89.17 KB (0%)
@sentry/browser (incl. metrics) 26.77 KB (0%)
@sentry/browser (incl. Feedback) 39.42 KB (0%)
@sentry/browser (incl. sendFeedback) 27.09 KB (0%)
@sentry/browser (incl. FeedbackAsync) 31.75 KB (0%)
@sentry/react 25.24 KB (0%)
@sentry/react (incl. Tracing) 37.25 KB (0%)
@sentry/vue 26.62 KB (0%)
@sentry/vue (incl. Tracing) 36.1 KB (0%)
@sentry/svelte 22.61 KB (0%)
CDN Bundle 23.69 KB (0%)
CDN Bundle (incl. Tracing) 35.94 KB (0%)
CDN Bundle (incl. Tracing, Replay) 70.36 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.62 KB (0%)
CDN Bundle - uncompressed 69.52 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 106.45 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 218.29 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 231.19 KB (0%)
@sentry/nextjs (client) 37.11 KB (0%)
@sentry/sveltekit (client) 34.82 KB (0%)
@sentry/node 115.51 KB (+0.04% 🔺)
@sentry/node - without tracing 89.91 KB (+0.06% 🔺)
@sentry/aws-serverless 99.34 KB (+0.04% 🔺)

'some-header': 'some-value',
}),
},
get clientAddress() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This simulates the AstroError that the framework throws if clientAddress is accessed.

@Lms24 Lms24 merged commit 38d9689 into develop Aug 12, 2024
97 checks passed
@Lms24 Lms24 deleted the lms/fix-astro-request-headers-dynamic-page-reqs branch August 12, 2024 11:49
Lms24 added a commit that referenced this pull request Aug 12, 2024
builds on top of #13306, found while working on #13116

This PR ensures that we correctly extract the request data in our Astro
middleware. Previously we didn't convert the `request.headers` object
into a `Record<string, string>` but simply passed a `Headers` instance.
This caused problems with the `requestDataIntegration` which doesn't
handle the instance correctly.
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.

Handle static routes in SSR-configured Astro applications
2 participants