Title: wrapFetchWithSentry quote scan breaks across chunks · Issue #23468 · getsentry/sentry-javascript · GitHub
Open Graph Title: wrapFetchWithSentry quote scan breaks across chunks · Issue #23468 · getsentry/sentry-javascript
X Title: wrapFetchWithSentry quote scan breaks across chunks · Issue #23468 · getsentry/sentry-javascript
Description: wrapFetchWithSentry rewrites the HTML response stream chunk-by-chunk to inject trace meta tags. The quote-scanning path in addMetaTagToHead is not sound across chunk boundaries, and a partner integration hit a build-breaking TanStack pre...
Open Graph Description: wrapFetchWithSentry rewrites the HTML response stream chunk-by-chunk to inject trace meta tags. The quote-scanning path in addMetaTagToHead is not sound across chunk boundaries, and a partner integ...
X Description: wrapFetchWithSentry rewrites the HTML response stream chunk-by-chunk to inject trace meta tags. The quote-scanning path in addMetaTagToHead is not sound across chunk boundaries, and a partner integ...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/23468
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"wrapFetchWithSentry quote scan breaks across chunks","articleBody":"`wrapFetchWithSentry` rewrites the HTML response stream chunk-by-chunk to inject trace meta tags. The quote-scanning path in `addMetaTagToHead` is not sound across chunk boundaries, and a partner integration hit a build-breaking TanStack prerender failure that is separate from the already-fixed React #418 newline issue.\n\nReported by a Cloudflare + TanStack Start partner integration. Observed on `@sentry/cloudflare` / related stack at `10.56.0`. The reporter confirmed the React hydration #418 half matches #21915 (fixed in `10.64.0`); this tracks the remaining stream-transform failure.\n\n**Verified**\n- On current `develop`, `packages/tanstackstart-react/src/server/wrapFetchWithSentry.ts` still processes each decoded chunk independently with:\n ```ts\n // Skip quoted attribute values so we don't match \u003chead> inside e.g. data-code=\"...\u003chead>...\"\n return htmlChunk.replace(/\"[^\"]*\"|'[^']*'|(\u003chead>)/g, ...)\n ```\n- The same file still documents an optimistic assumption that HTML chunks will not split inside `\u003chead>`; if they do, injection is skipped rather than carried across chunks.\n- Related closed issues do **not** cover this failure mode:\n - #21915 — newline in `getTraceMetaTags` caused React #418 (fixed in `10.64.0` via #22004)\n - #23305 — UTF-8 multi-byte characters corrupted across stream chunks in React Router injectors\n\n**Reported symptoms**\n- TanStack SSR stream transform threw `SSR stream tail exceeded maximum buffer` during prerender and failed the build\n- Failure was timing/chunk-boundary dependent: passed locally, failed in CI\n- Partner hypothesis (medium confidence): a chunk boundary inside a quoted attribute value can desynchronize the per-chunk quote scan and misparse markup, independent of the newline fix\n\n**Workaround**\n- Omit `wrapFetchWithSentry` when tracing is not needed (`tracesSampleRate: 0`); middleware-only setup was sufficient for the reporter\n- Bump to `>=10.64.0` for the separate #418 newline fix, then re-test the wrapper if tracing is enabled\n\n**Unknown**\n- Exact TanStack Start / React versions in the failing app\n- Minimal public reproduction\n- Whether the buffer error is caused only by quote-scan desync, by `\u003chead>` split across chunks, by interaction with TanStack prerender buffering, or a combination\n\n\u003c!-- junior-request-attribution:start -->\nRequested by **Nicolas Hrubec**.\n\u003c!-- junior-request-attribution:end -->\n\n\u003c!-- junior-session-footer:start -->\n\u003c!-- junior-conversation-id:slack%3ACA2V2LBDL%3A1787130280.267509 -->\n\n--\n\n[View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3ACA2V2LBDL%3A1787130280.267509) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3ACA2V2LBDL%3A1787130280.267509/?project=4510944073809921)\n\n\u003c!-- junior-session-footer:end -->","author":{"url":"https://github.com/apps/sentry-junior","@type":"Person","name":"sentry-junior"},"datePublished":"2026-08-20T21:58:11Z","url":"https://github.com/getsentry/sentry-javascript/issues/23468"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6c43df0e-d26f-4867-0399-3b3d02ef84ca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9BA:248DA8:11576A2:169EF54:6B04F4AE |
| html-safe-nonce | 7d130c5df2f5ef7e6fa10a91ddd972fad8834ee22de63ccffa2971f6d99eedac |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUJBOjI0OERBODoxMTU3NkEyOjE2OUVGNTQ6NkIwNEY0QUUiLCJ2aXNpdG9yX2lkIjoiODUwOTY3MTIyODUxNTM0OTY3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3e253a7c405dc3fd0d0c3e157ef8e8d2a55c9eaa6db434523134fbe8c652fad6 |
| hovercard-subject-tag | issue:5208247868 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/23468/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8d2894627b0dd596798a18f649424c85bdd38afe451ddca0e99371bc95fa6344/getsentry/sentry-javascript/issues/23468 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8d2894627b0dd596798a18f649424c85bdd38afe451ddca0e99371bc95fa6344/getsentry/sentry-javascript/issues/23468 |
| og:image:alt | wrapFetchWithSentry rewrites the HTML response stream chunk-by-chunk to inject trace meta tags. The quote-scanning path in addMetaTagToHead is not sound across chunk boundaries, and a partner integ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sentry-junior[bot] |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2c3971d6ab4be607cf9a26ac26ef0a7bfce380ec2ba14642e64028ad07a492b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b3f1d45dee14b3f87c64e9017a9c08d011561786 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width