sentry icon indicating copy to clipboard operation
sentry copied to clipboard

Wrapping of Function.prototype.toString causes inconsistent behavior of wrapped functions

Open DerGernTod opened this issue 1 year ago • 4 comments

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

  1. go to a sentry-injected page
  2. run XMLHttpRequest.prototype.open.toString() - it returns function () { [native code] } even though it's wrapped by sentry
  3. run XMLHttpRequest.prototype.open.name - it returns "", because it's wrapped by sentry but the wrapper doesn't forward the property access like it forwards the toString call

Expected Result

access to XMLHttpRequest.prototype.open.name returns "open"

Actual Result

access to XMLHttpRequest.prototype.open.name returns ""

This can cause interoperability issues with other tracking services.

Product Area

Issues - Suggested Fix

Link

No response

DSN

No response

Version

No response

DerGernTod avatar May 21 '24 14:05 DerGernTod

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar May 21 '24 14:05 getsantry[bot]

my suggestion for a fix would be to implement the access to other Function.prototype properties similar to the toString function - forward the call to the native function to behave consistent

DerGernTod avatar May 21 '24 14:05 DerGernTod

hi @DerGernTod thanks for reaching out, are you using self-hosted Sentry? If not, would you mind checking the link you provided? It currently points to sentry.sentry.io. Thanks in advance!

dalnoki avatar May 22 '24 11:05 dalnoki

i'm not using sentry on my own, i just had to deal with this issue as a third party vendor.

you can reproduce the issue on https://sentry.io/welcome/ for example. simply open the console and type XMLHttpRequest.prototype.open.name - it shouldn't return an empty string

DerGernTod avatar May 22 '24 11:05 DerGernTod