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

fix: allow optional abs_path and lineno for JsFrame #1581

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

samuelmaddock
Copy link

@samuelmaddock samuelmaddock commented Jan 8, 2025

fixes #1580

It's possible for V8 to format a JS frame location to only contain <anonymous> (see AppendFileLocation). In such cases, JSON deserialization should pass, but symbolification should fail.

Here's an example call stack this addresses:

Error: Example unresponsive call stack
    at Object.hasOwnProperty (<anonymous>)

Also, this is the first Rust code I've written so please lmk what can be improved!

@samuelmaddock samuelmaddock force-pushed the fix/optional-frame-props branch from 829c938 to 13cc9d3 Compare January 8, 2025 22:27
@samuelmaddock samuelmaddock force-pushed the fix/optional-frame-props branch from 13cc9d3 to 2b799fe Compare January 8, 2025 22:28
crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
crates/symbolicator-js/src/lookup.rs Outdated Show resolved Hide resolved
crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
@Dav1dde Dav1dde requested a review from loewenheim January 9, 2025 08:16
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 68.85246% with 19 lines in your changes missing coverage. Please review.

Project coverage is 73.59%. Comparing base (5a85fd7) to head (32ce6d9).
Report is 205 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1581      +/-   ##
==========================================
- Coverage   76.09%   73.59%   -2.50%     
==========================================
  Files         101      105       +4     
  Lines       15262    15912     +650     
==========================================
+ Hits        11613    11710      +97     
- Misses       3649     4202     +553     

Copy link
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

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

Just left some small Rust nits, otherwise looks good to me, but I want to wait on @loewenheim for a review, since I can't really judge the implications of the change fully.

Also would be great if you can add a test, I think symbolicator-js/tests/integration/sourcemap.rs should be the right place and pretty low effort to add.

crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
@@ -154,7 +162,7 @@ async fn symbolicate_js_frame(
.map(|entry| entry.sourcemap_url())
.ok()
.flatten()
.unwrap_or_else(|| raw_frame.abs_path.clone());
.unwrap_or_else(|| raw_frame.abs_path.clone().unwrap_or_default());
Copy link
Member

Choose a reason for hiding this comment

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

Can use abs_path.to_owned() here now, I think, since we already checked for Some before.

Suggested change
.unwrap_or_else(|| raw_frame.abs_path.clone().unwrap_or_default());
.unwrap_or_else(|| abs_path.to_owned());

Copy link
Author

Choose a reason for hiding this comment

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

I had to revert this in 12d1d5e to fix a compilation error

error[E0502]: cannot borrow `*raw_frame` as mutable because it is also borrowed as immutable
   --> crates/symbolicator-js/src/symbolication.rs:145:17
    |
105 |   ...ath = raw_frame
    |  __________-
106 | | ...path
    | |_______- immutable borrow occurs here
...
145 |   ...   apply_source_context(raw_frame, minified_source.contents(...
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
...
163 |   ...ap_or_else(|| abs_path.to_owned());
    |                    -------- immutable borrow later captured here by closure

Copy link
Contributor

Choose a reason for hiding this comment

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

If you clone abs_path at the top of the function this just becomes

Suggested change
.unwrap_or_else(|| raw_frame.abs_path.clone().unwrap_or_default());
.unwrap_or(abs_path.clone());

crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
@samuelmaddock
Copy link
Author

@Dav1dde I've added a couple snapshot tests in 41144b1

@samuelmaddock samuelmaddock requested a review from Dav1dde January 10, 2025 15:55
@samuelmaddock
Copy link
Author

@Dav1dde @loewenheim Our product will start receiving a higher volume of these unsymbolicated call stacks next week. Is there a timeline we can follow for how soon an update to the symbolicator service might be deployed by Sentry?

@loewenheim
Copy link
Contributor

@samuelmaddock I was under the impression that you wanted this because you are running Symbolicator yourself, did I misunderstand that? On Sentry's side nothing will immediately change even when this is deployed—we don't send frames without abs_path to Symbolicator; they are separated out and then merged back into the symbolicated stacktrace that comes back from Symbolicator.

crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
@@ -154,7 +162,7 @@ async fn symbolicate_js_frame(
.map(|entry| entry.sourcemap_url())
.ok()
.flatten()
.unwrap_or_else(|| raw_frame.abs_path.clone());
.unwrap_or_else(|| raw_frame.abs_path.clone().unwrap_or_default());
Copy link
Contributor

Choose a reason for hiding this comment

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

If you clone abs_path at the top of the function this just becomes

Suggested change
.unwrap_or_else(|| raw_frame.abs_path.clone().unwrap_or_default());
.unwrap_or(abs_path.clone());

crates/symbolicator-js/src/symbolication.rs Outdated Show resolved Hide resolved
@samuelmaddock
Copy link
Author

@samuelmaddock I was under the impression that you wanted this because you are running Symbolicator yourself, did I misunderstand that? On Sentry's side nothing will immediately change even when this is deployed—we don't send frames without abs_path to Symbolicator; they are separated out and then merged back into the symbolicated stacktrace that comes back from Symbolicator.

@loewenheim Maybe I'm misunderstanding the underlying problem in that case.

We have call stacks being sent to Sentry which are formatted like the example in the PR description. Our events within our non-self-hosted Sentry are not being symbolicated. I copied the exception.values[0].stacktrace from the event's JSON API response and found that a locally hosted symbolicator service refuses to symbolicate it with the error:

Failed to deserialize the JSON body into the target type: stacktraces[0].frames[0]: missing field `abs_path` at line 1 column 220

My hope was that by fixing this issue in the symbolicator service, it will also fix it in Sentry once the fix has been deployed.

It's possible we've made a configuration error which is preventing symbolication, but it has been working for other events. Is there a better place we could raise this issue?

@loewenheim
Copy link
Contributor

Oh shoot, in that case there's been a miscommunication. No, SaaS is already robust against stack frames without abs_paths. Can you post a link to an event that isn't symbolicated as you would expect, or email it to me at [email protected]?

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.

Call stacks containing <anonymous> source fail to symbolicate
3 participants