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

Default setting for autoInstrumentation.requestHandler as true can truncate MDX output in Astro #9985

Closed
3 tasks done
knpwrs opened this issue Dec 27, 2023 · 3 comments
Closed
3 tasks done
Labels
Package: browser Issues related to the Sentry Browser SDK Type: Bug

Comments

@knpwrs
Copy link

knpwrs commented Dec 27, 2023

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

7.91.0

Framework Version

Astro 4.0.7

Link to Sentry event

No response

SDK Setup

export default defineConfig({
  integrations: [
    mdx(),
    sentry({
      debug: true,
      enabled: process.env.NODE_ENV === 'production',
      dsn: '...',
      sourceMapsUploadOptions: {
        project: 'letschurch-astro',
        authToken: process.env.SENTRY_AUTH_TOKEN,
      },
      autoInstrumentation: {
        requestHandler: true,
      },
    }),
  ],
  output: 'server',
  adapter: node({
    mode: 'standalone',
  }),
});

Steps to Reproduce

I am unable to reproduce this issue in isolation and I am seeking further debugging steps.

In my project when I have autoInstrumentation.requestHandler set to true (either as above, or by not specifying autoInstrumentation at all and letting the default value take effect) mdx pages are truncated. Short pages are blank, and long pages have the end cut off.

This does not happen with md or astro pages, only mdx.

Expected Result

The following screenshots are from the end of a long mdx page when autoInstrumentation.requestHandler is set to false:

image

image

Actual Result

These screenshots are from the end of that same long mdx page when autoInstrumentation.requestHandler is set to true (or unspecified):

image

image
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Dec 27, 2023
@github-actions github-actions bot added the Package: browser Issues related to the Sentry Browser SDK label Dec 27, 2023
@knpwrs
Copy link
Author

knpwrs commented Dec 27, 2023

This is also in the astro/vite watch dev server, I have not been able to try a built version yet.

@lforst
Copy link
Member

lforst commented Dec 28, 2023

I have a suspicion that we are somehow truncating the response stream here:

const newResponseStream = new ReadableStream({
start: async controller => {
for await (const chunk of originalBody) {
const html = typeof chunk === 'string' ? chunk : decoder.decode(chunk);
const modifiedHtml = addMetaTagToHead(html, scope, client, span);
controller.enqueue(new TextEncoder().encode(modifiedHtml));
}
controller.close();
},
});
.

Superficially looking at it I don't see anything immediately wrong. I also have yet to reproduce

I would have one thing I would want to try which would affect non-strictly-utf8-encoded streams: #9989

Maybe you could try an isolated reproduction with non-utf8-encoded files?

I will have @Lms24 take a more educated look next week!

@AbhiPrasad
Copy link
Member

We shipped the change mentioned by Luca in https://github.com/getsentry/sentry-javascript/releases/tag/7.92.0 - please give it a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: browser Issues related to the Sentry Browser SDK Type: Bug
Projects
Archived in project
Development

No branches or pull requests

3 participants