Skip to content

Commit

Permalink
feat(js): Temporarily sample failing lookups with debug ids (#1607)
Browse files Browse the repository at this point in the history
This captures 1 in 10_000 cases of a source or sourcemap lookup
failing even though a debug id is available as a Sentry error.
This is to gain some insight into how that can happen.
  • Loading branch information
loewenheim authored Jan 31, 2025
1 parent 1fd7ec6 commit 609e93b
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 25 deletions.
130 changes: 106 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/symbolicator-js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ futures = "0.3.12"
humantime = "2.1.0"
moka = { version = "0.12.8", features = ["future", "sync"] }
once_cell = "1.17.1"
rand = "0.9.0"
regex = "1.5.5"
reqwest = { workspace = true, features = [
"gzip",
Expand Down
29 changes: 28 additions & 1 deletion crates/symbolicator-js/src/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,28 @@ impl ArtifactFetcher {
Option<CachedFileEntry<OwnedSourceMapCache>>,
) {
// First, check if we have already cached / created the `SourceMapCache`.
let key = FileKey::MinifiedSource { abs_path, debug_id };
let key = FileKey::MinifiedSource {
abs_path: abs_path.clone(),
debug_id,
};

// Fetch the minified file first
let minified_source = self.get_file(&key).await;
if minified_source.entry.is_err() {
self.metrics
.record_not_found(SourceFileType::Source, debug_id.is_some());

// Temporarily sample cases of a file not being found even though it has a debug id.
if let Some(debug_id) = debug_id {
if rand::random::<f64>() < 0.0001 {
tracing::error!(
source_url = %self.source.url,
abs_path,
%debug_id,
"Failed to fetch source with debug id"
);
}
}
}

// Then fetch the corresponding sourcemap reference and debug_id
Expand Down Expand Up @@ -622,6 +637,18 @@ impl ArtifactFetcher {
} else if sourcemap.entry.is_err() {
self.metrics
.record_not_found(SourceFileType::SourceMap, debug_id.is_some());

// Temporarily sample cases of a file not being found even though it has a debug id.
if let Some(debug_id) = debug_id {
if rand::random::<f64>() < 0.0001 {
tracing::error!(
source_url = %self.source.url,
abs_path,
%debug_id,
"Failed to fetch sourcemap with debug id"
);
}
}
}

// Now that we (may) have both files, we can create a `SourceMapCache` for it
Expand Down

0 comments on commit 609e93b

Please sign in to comment.