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

RewriteFrames not functional in browser environments #6423

Closed
3 tasks done
Tracked by #9508
segevfiner opened this issue Dec 5, 2022 · 4 comments · Fixed by #11535
Closed
3 tasks done
Tracked by #9508

RewriteFrames not functional in browser environments #6423

segevfiner opened this issue Dec 5, 2022 · 4 comments · Fixed by #11535

Comments

@segevfiner
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/vue

SDK Version

7.23.0

Framework Version

Vue 3.2.40

Link to Sentry event

https://sentry.io/organizations/swimm/issues/3788945788/events/387150439b9a4cb787c4582e97bd40ae/?project=4504236048646144&query=is%3Aunresolved&referrer=previous-event

Steps to Reproduce

We have a virtual server (Inside a VS Code webview, they use a ServiceWorker to simulate it internally), that hosts our assets under a dynamic subdirectory, which is in fact the full path to the file on the users system. As such the filenames in the reported Sentry stack traces include prefix and don't match the uploaded source maps which are uploaded without it. As it is dynamic, I can't just use urlPrefix, so as in similar cases I tried to use RewriteFrames to normalize the uploaded paths to match the actual root Sentry knows about. But... RewriteFrames doesn't do anything in the browser by default when just specifying root, and it looks like I'll have to write my own iteratee. This is not very convenient. I'd rather it just worked given the proper root path to strip even in browser context.

Steps to Reproduce:

  1. Install Sentry in any web project hosted in a web server subdirectory, yet don't use urlPrefix, instead try to use RewriteFrames to normalizes the paths.

Expected Result

RewriteFrames should support such scenarios.

Actual Result

It doesn't do anything due to the check at

if (isWindowsFrame || startsWithSlash) {
, as it doesn't know how to handle URLs instead of paths.

@segevfiner
Copy link
Author

Ended up doing something like this (We are setting the base in an HTML base tag):

      new RewriteFrames({
        // https://github.com/getsentry/sentry-javascript/issues/6423
        iteratee(frame) {
          if (!frame.filename) {
            return frame;
          }

          const re = new RegExp(`^${escapeRegExp(document.head.baseURI)}`);
          frame.filename = frame.filename.replace(re, 'app:///');

          return frame;
        },
      }),

This is harder then it should have been...

@lforst
Copy link
Member

lforst commented Dec 6, 2022

Hi, thanks for writing in. How exactly would you have wanted the root option to behave here?

@segevfiner
Copy link
Author

I want to give it my website root path or full URL, and have it stripped from the start of filenames, kinda like what I'm doing in the code snippet I sent, this was what I needed to do to handle the dynamic subpath this web page is served under.

@lforst
Copy link
Member

lforst commented Dec 6, 2022

Makes sense. Considering that this is somewhat breaking behaviour I think we should do this in a major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants