You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @netpok, thank you for reaching out, and thank you for providing a full reproduction of the issue; it makes it much easier for us to help.
Unfortunately, the error you are observing is to be expected, since the sourceMappingURL is invalid.
For an embedded sourcemap, the sourceMapURL should look like the following:
//# sourceMappingURL=data:application/json;base64,[base-64 encoded data here]
But, in your case, the part where we would expect the base-64 encoded data to be instead contains this string: `+wt.btoa(unescape(encodeURIComponent(JSON.stringify(Z))))),v+\`.
Most likely, a template engine is supposed to replace this string with the actual base-64 encoded sourcemap data, but due to some bug or misconfiguration with your bundler, this is not happening, and so the template string is being copied into your compiled JavaScript source file.
I would suggest checking your bundler configuration, and if you cannot find any problems, I would recommend raising an issue with your bundler or possibly with PaperJS. Something is going wrong in the compilation process, before Sentry CLI is invoked.
After further investigation, I have traced the source of this bug to one of our dependencies, symbolic-debuginfo, which lives in Sentry's symbolic repository. I am going to transfer this issue over to that repository, since we need to fix this bug there. Afterwards, we can update the dependency in Sentry CLI.
Specifically, the problem lies with the following function, which is supposed to find //# sourceMappingUrl comments.
if line.starts_with("//# sourceMappingURL=") || line.starts_with("//@ sourceMappingURL="){
let url = line[21..].trim();
// The URL might contain a query string or fragment. Strip those away before recording the URL.
let without_query = url.split_once('?').map(|x| x.0).unwrap_or(url);
let without_fragment = without_query
.split_once('#')
.map(|x| x.0)
.unwrap_or(without_query);
returnSome(without_fragment);
}
}
None
}
This function does not consider the possibility of a //# sourceMappingUrl comment appearing in a multiline string. We will likely need to implement some more robust parsing logic here. Perhaps, there is a crate which can parse JS files.
Activity
szokeasaurusrex commentedon Nov 27, 2024
Hi @netpok, thank you for reaching out, and thank you for providing a full reproduction of the issue; it makes it much easier for us to help.
Unfortunately, the error you are observing is to be expected, since the
sourceMappingURLis invalid.For an embedded sourcemap, the
sourceMapURLshould look like the following://# sourceMappingURL=data:application/json;base64,[base-64 encoded data here]But, in your case, the part where we would expect the base-64 encoded data to be instead contains this string:
`+wt.btoa(unescape(encodeURIComponent(JSON.stringify(Z))))),v+\`.Most likely, a template engine is supposed to replace this string with the actual base-64 encoded sourcemap data, but due to some bug or misconfiguration with your bundler, this is not happening, and so the template string is being copied into your compiled JavaScript source file.
I would suggest checking your bundler configuration, and if you cannot find any problems, I would recommend raising an issue with your bundler or possibly with PaperJS. Something is going wrong in the compilation process, before Sentry CLI is invoked.
netpok commentedon Nov 27, 2024
Hi @szokeasaurusrex,
I still think this is an error because it's not an embedded sourcemap, it's a javascript string literal that is used to add a sourcemap to a file, originating from here: https://github.com/paperjs/paper.js/blob/92775f5279c05fb7f0a743e9e7fa02cd40ec1e70/src/core/PaperScript.js#L441
The
\nis replaced with a new line by esbuild.For example this bug also makes impossible to strip similar sourcemaps with the following code:
szokeasaurusrex commentedon Nov 27, 2024
Oh, I think I missed the
`on the previous line:So, the
//# sourceMappingURLis not a code comment, just a part of a multiline string literal.In this case, I think that yes, this is a bug.
szokeasaurusrex commentedon Mar 4, 2025
After further investigation, I have traced the source of this bug to one of our dependencies,
symbolic-debuginfo, which lives in Sentry'ssymbolicrepository. I am going to transfer this issue over to that repository, since we need to fix this bug there. Afterwards, we can update the dependency in Sentry CLI.Specifically, the problem lies with the following function, which is supposed to find
//# sourceMappingUrlcomments.symbolic/symbolic-debuginfo/src/js.rs
Lines 13 to 29 in 67b533b
This function does not consider the possibility of a
//# sourceMappingUrlcomment appearing in a multiline string. We will likely need to implement some more robust parsing logic here. Perhaps, there is a crate which can parse JS files.loewenheim commentedon Mar 4, 2025
Thank you for the report, @netpok and @szokeasaurusrex. We'll discuss it in the team.