sentry-cli: List of known `sourcemap inject` bugs
- We have gotten customer reports of injection problems when a file starts with something like
(this.foo=this.bar||[]).push([[2],[function(e,t,n){"use strict"; […] }
This trips the “use pragma” detection and causes the line to be skipped, which is obviously not intended. Solution: make the regex stricter.
- Block comments aren’t handled at all. Thus, if a file started with
/* lol, lmao */
"use strict";
we would erroneously inject at the very top. Solution: handle block comments.
'use strict';can be on the same line as the rest of the code, eg'use strict';(function(){console.log('wat')})();is a valid code, and we do not handle injecting snippet “in-between” - ref: https://github.com/getsentry/sentry-cli/issues/1646
### Tasks
- [ ] https://github.com/getsentry/sentry-cli/pull/1648
- [x] Handle block comments
- [x] Handle same-line `use strict` usages
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (8 by maintainers)
All of these bugs should be fixed as of
sentry-cli 2.20.4. Thank you very much for your forbearance, eveyone 🙇I am sorry for the frustration caused by this. We’re currently working on putting injection on a more solid foundation.
I have something to add to this list. We are using GraphQL and sometimes the injection gets injected into the template string that is defining out GraphQL queries. Here is a couple snippets to show you:
This is a minified Angular App
Yes, sorry. Thanks for catching this. I meant to close linked issue only 😅
We just got bit by this badly, simplified reproducer:
Original js file:
Minified:
Debug ids Injected:
As you can see this is pretty bad, it ends up inserting the sentry debug snippet inside the
myHTMLvariable. Are there any workarounds available ? When can we expect this to be fixed ? We had to disable sourcemap support because of this, making the Sentry issues mostly unreadable.