Created
June 11, 2023 06:18
-
-
Save jasonLaster/acb39cc036758b6238aee265fe9f205e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/hooks/useFetchCrashReports.ts b/src/hooks/useFetchCrashReports.ts | |
index a3f636d..75760b9 100644 | |
--- a/src/hooks/useFetchCrashReports.ts | |
+++ b/src/hooks/useFetchCrashReports.ts | |
@@ -21,6 +21,13 @@ import { | |
import hackfix_pruneBadCrashReports from "../utils/crash-pruning"; | |
let ids = new Set<string>(); | |
+let cannotFindContextCount = 0; | |
+function matchesCannotFindContext(report: DBCrashReport) { | |
+ return report.crash_report.process?.text?.match( | |
+ /Cannot find .*context.*-32000/ | |
+ ); | |
+} | |
+ | |
const defaultValue = { | |
crash_reports: [], | |
oldest: "", | |
@@ -84,7 +91,8 @@ export function useFetchCrashReports(crashOptions: CrashOptions) { | |
// Keep fetching crashes following the last fetched crash, or | |
// restart at cutoff date. | |
- const youngestDate = cache.data.youngest && new Date(cache.data.youngest) || undefined; | |
+ const youngestDate = | |
+ (cache.data.youngest && new Date(cache.data.youngest)) || undefined; | |
const cutoffDate = getNow(daysPrior); | |
const created_at = youngestDate > cutoffDate ? youngestDate : cutoffDate; | |
return { | |
@@ -133,14 +141,21 @@ export function useFetchCrashReports(crashOptions: CrashOptions) { | |
const cutoffDate = getNow(daysPrior); | |
let newCrashReports: DBCrashReport[] = []; | |
+ const maybeAddReport = (report: DBCrashReport) => { | |
+ // Add the first 2,000 cannot-find-context reports and exclude the rest. | |
+ if (matchesCannotFindContext(report) && cannotFindContextCount++ > 2000) { | |
+ return; | |
+ } | |
+ | |
+ newCrashReports.push(report); | |
+ }; | |
+ | |
// 3. Drop old reports. | |
for (const crash of originalCrashReports) { | |
- if ( | |
- new Date(crash.created_at) < cutoffDate | |
- ) { | |
+ if (new Date(crash.created_at) < cutoffDate) { | |
continue; | |
} | |
- newCrashReports.push(crash); | |
+ maybeAddReport(crash); | |
} | |
// 4. Add new reports. | |
@@ -150,9 +165,9 @@ export function useFetchCrashReports(crashOptions: CrashOptions) { | |
} | |
ids.add(crash.id); | |
- newCrashReports.push(crash); | |
+ maybeAddReport(crash); | |
} | |
- newCrashReports = hackfix_pruneBadCrashReports(newCrashReports); | |
+ | |
const oldest = minBy(newCrashReports, "created_at"); | |
const youngest = maxBy(newCrashReports, "created_at"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment