Skip to content

fix(v10/core): Call native toString without page-replaceable lookups in FunctionToString - #25922

Merged
logaretm merged 1 commit into
v10from
awad/v10-function-to-string-bound-native-call
Oct 30, 2026
Merged

logaretm merged 1 commit into
v10from
awad/v10-function-to-string-bound-native-call

Conversation

@logaretm

@logaretm logaretm commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Backport of: #25921


FunctionToString could overflow the stack, it happens when a page hooks Function.prototype.apply or when toString gets a huge argument list, this can be fixed by capturing a binding to the native call once and passing no arguments.

Why does a huge argument list trigger this? V8 only fits so many args on the stack. Our wrapper held two copies (the incoming call and our call to native toString), so a huge list overflows where native's single copy fits. This is mentioned on MDN.

I added tests for an apply hook that calls toString and a 100k argument call, both overflow before the fix.

Related to #22515, which removed the same kind of re-entry through Reflect.apply. This is a guess at best at an issue that was reported, no guarantee it fixes it because it seems far fetched that this is what happened.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.3 kB added added
@sentry/browser - with treeshaking flags 26.75 kB added added
@sentry/browser (incl. Tracing) 47.31 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 49.11 kB added added
@sentry/browser (incl. Tracing, Profiling) 52.1 kB added added
@sentry/browser (incl. Tracing, Replay) 86.76 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.39 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 91.48 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 104.1 kB added added
@sentry/browser (incl. Feedback) 45.48 kB added added
@sentry/browser (incl. sendFeedback) 33.11 kB added added
@sentry/browser (incl. FeedbackAsync) 38.23 kB added added
@sentry/browser (incl. Metrics) 29.39 kB added added
@sentry/browser (incl. Logs) 29.63 kB added added
@sentry/browser (incl. Metrics & Logs) 30.31 kB added added
@sentry/react 30.13 kB added added
@sentry/react (incl. Tracing) 49.62 kB added added
@sentry/vue 34.19 kB added added
@sentry/vue (incl. Tracing) 49.69 kB added added
@sentry/svelte 28.32 kB added added
CDN Bundle 30.72 kB added added
CDN Bundle (incl. Tracing) 49.29 kB added added
CDN Bundle (incl. Logs, Metrics) 32.32 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 50.61 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 71.81 kB added added
CDN Bundle (incl. Tracing, Replay) 87.02 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.32 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 92.83 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.11 kB added added
CDN Bundle - uncompressed 91.27 kB added added
CDN Bundle (incl. Tracing) - uncompressed 148.53 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 95.98 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 221.47 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 268.5 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.46 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 282.2 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.15 kB added added
@sentry/nextjs (client) 52.29 kB added added
@sentry/sveltekit (client) 47.76 kB added added
@sentry/core/server 81.7 kB added added
@sentry/core/browser 67.75 kB added added
@sentry/node-core 64.13 kB added added
@sentry/node 127.32 kB added added
@sentry/node (incl. diagnostics channel injection) 171.51 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 166 B added added
@sentry/node/light 52.24 kB added added
@sentry/node - without tracing 75.92 kB added added
@sentry/aws-serverless 85.08 kB added added
@sentry/cloudflare (withSentry) - minified 205.02 kB added added
@sentry/cloudflare (withSentry) 505.56 kB added added

@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e2ecfd9. Configure here.

@logaretm
logaretm marked this pull request as ready for review October 30, 2026 03:19
@logaretm
logaretm merged commit 97630b3 into v10 Oct 30, 2026
320 checks passed
@logaretm
logaretm deleted the awad/v10-function-to-string-bound-native-call branch October 30, 2026 14:13
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.

2 participants