Skip to content

fix(tanstackstart-react): avoid double-injecting trace meta tags across stream chunks - #23480

Draft
nicohrubec wants to merge 1 commit into
developfrom
feat/tanstackstart-fix-chunk-meta-double-inject
Draft

fix(tanstackstart-react): avoid double-injecting trace meta tags across stream chunks#23480
nicohrubec wants to merge 1 commit into
developfrom
feat/tanstackstart-fix-chunk-meta-double-inject

Conversation

@nicohrubec

@nicohrubec nicohrubec commented Aug 21, 2026

Copy link
Copy Markdown
Member

wrapFetchWithSentry rewrites the SSR HTML stream chunk-by-chunk to inject trace meta tags into <head>. Each chunk is scanned independently, so a <head> that appears inside a quoted attribute value in a later chunk gets injected into a second time.

Example — a document split so the real <head> and a second heat tag in an attribute land in different chunks:

chunk 1: <head></head><body><div data-content="junk
chunk 2: <head>junk"></div></body>

result:  <head>[meta]</head>...<div data-content="junk<head>[meta]junk">...
                                                        ^ injected into an attribute value

This breaks because the per-chunk scan has no memory that injection already happened in an earlier chunk. This fix injects at the first <head> and then passes later chunks through untouched.

Note: This should fix a bug in the injection logic but not entirely sure this is the root cause of the attached issue (hard to reproduce since this depends on how the chunks get split up).

Fixes #23468

…ss stream chunks

Inject the trace meta tags at the first <head> and pass subsequent stream
chunks through untouched, so a <head> appearing inside a quoted attribute
value in a later chunk is no longer matched a second time.

Fixes #23468

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.3 kB - -
@sentry/browser - with treeshaking flags 28.47 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.59 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.46 kB - -
@sentry/browser (incl. Tracing, Replay) 87.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.36 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.7 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.39 kB - -
@sentry/browser (incl. Feedback) 47.65 kB - -
@sentry/browser (incl. sendFeedback) 35.13 kB - -
@sentry/browser (incl. FeedbackAsync) 40.28 kB - -
@sentry/browser (incl. Metrics) 31.24 kB - -
@sentry/browser (incl. Logs) 31.52 kB - -
@sentry/browser (incl. Metrics & Logs) 32.15 kB - -
@sentry/react 32.09 kB - -
@sentry/react (incl. Tracing) 50.77 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.54 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.9 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.31 kB - -
CDN Bundle (incl. Tracing, Replay) 86.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.31 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.12 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.75 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.44 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.37 kB - -
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 49 kB - -
@sentry/core/server 65.38 kB - -
@sentry/core/browser 51.72 kB - -
@sentry/node 117.4 kB +0.02% +22 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.08 kB - -
@sentry/node - without tracing 81.91 kB +0.03% +23 B 🔺
@sentry/aws-serverless 91.32 kB +0.03% +24 B 🔺
@sentry/cloudflare (withSentry) - minified 213.98 kB - -
@sentry/cloudflare (withSentry) 528.93 kB - -

View base workflow run

@nicohrubec
nicohrubec marked this pull request as ready for review August 21, 2026 10:46
@nicohrubec
nicohrubec requested a review from a team as a code owner August 21, 2026 10:46
@nicohrubec
nicohrubec requested review from chargome and s1gr1d and removed request for a team August 21, 2026 10:46
@nicohrubec
nicohrubec marked this pull request as draft August 21, 2026 10:55
@nicohrubec

Copy link
Copy Markdown
Member Author

still trying if I can get a reproduction for this, putting in draft for now

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.

wrapFetchWithSentry quote scan breaks across chunks

1 participant