mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
Merge pull request #1963 from PR0M3TH3AN/telemetry-aggregation-fix-6349074633801704985
Refactor telemetry aggregator regex for stricter error detection
This commit is contained in:
3 files changed
+10
-7
No files matched your search
+1
-1
@@ -7,7 +7,7 @@
|
||||
"start": "npm run build && npx serve",
|
||||
"serve": "npx serve",
|
||||
"build": "node scripts/build-dist.mjs",
|
||||
"build:css": "npx tailwindcss -c tailwind.config.cjs -i css/tailwind.source.css -o css/tailwind.generated.css --minify",
|
||||
"build:css": "tailwindcss -c tailwind.config.cjs -i css/tailwind.source.css -o css/tailwind.generated.css --minify",
|
||||
"build:beacon:bundle": "node scripts/build-beacon.mjs",
|
||||
"build:beacon": "npm run build:beacon:bundle && npm run lint:inline-styles",
|
||||
"ci:beacon": "npm run build:beacon",
|
||||
|
||||
@@ -147,19 +147,26 @@ function collectGenericLogs(filepath, sourceName) {
|
||||
for (const line of lines) {
|
||||
// Simple heuristic for generic logs: look for "Error:" or "Exception:"
|
||||
// and capture following lines that look like stack traces (start with 'at ' or are indented)
|
||||
// Also support bracketed log levels like [ERROR], [FAIL], [CRITICAL], [WARN]
|
||||
|
||||
const isErrorStart = /Error:|Exception:|FAIL|CRITICAL/.test(line);
|
||||
const errorMatch = line.match(/(?:\[\s*(?:ERROR|FAIL|CRITICAL|EXCEPTION|WARN|WARNING)\s*\])|(?:\b(?:Error|Exception|Warning):)|(?:\b(?:FAIL|CRITICAL)\b)/i);
|
||||
const isErrorStart = !!errorMatch;
|
||||
const isStackLine = /^\s+at /.test(line) || /^\s+/.test(line); // Indented lines often follow errors
|
||||
|
||||
if (isErrorStart) {
|
||||
if (currentError) {
|
||||
errors.push(currentError);
|
||||
}
|
||||
|
||||
let severity = 'High';
|
||||
if (line.match(/CRITICAL/i)) severity = 'Critical';
|
||||
else if (line.match(/WARN|WARNING/i)) severity = 'Medium';
|
||||
|
||||
currentError = {
|
||||
source: sourceName,
|
||||
title: sanitize(line.trim()),
|
||||
details: [sanitize(line.trim())],
|
||||
severity: 'High'
|
||||
severity: severity
|
||||
};
|
||||
} else if (currentError && isStackLine) {
|
||||
currentError.details.push(sanitize(line.trim()));
|
||||
|
||||
@@ -55,11 +55,9 @@ test("batchFetchProfiles handles fast and failing relays", async () => {
|
||||
const originalWriteRelays = Array.isArray(nostrClient.writeRelays)
|
||||
? [...nostrClient.writeRelays]
|
||||
: nostrClient.writeRelays;
|
||||
// Make sure to backup readRelays too
|
||||
const originalReadRelays = Array.isArray(nostrClient.readRelays)
|
||||
? [...nostrClient.readRelays]
|
||||
: nostrClient.readRelays;
|
||||
|
||||
const originalPool = nostrClient.pool;
|
||||
|
||||
const poolListCalls = [];
|
||||
@@ -67,9 +65,7 @@ test("batchFetchProfiles handles fast and failing relays", async () => {
|
||||
nostrClient.relays = [FAST_RELAY, FAIL_RELAY];
|
||||
nostrClient.readRelays = [FAST_RELAY, FAIL_RELAY];
|
||||
nostrClient.writeRelays = [FAST_RELAY, FAIL_RELAY];
|
||||
// Mock readRelays to match relays, avoiding duplicate/extra queries if the implementation prioritizes them
|
||||
nostrClient.readRelays = [FAST_RELAY, FAIL_RELAY];
|
||||
|
||||
nostrClient.pool = {
|
||||
list: (relays, filters) => {
|
||||
poolListCalls.push({ relays, filters });
|
||||
|
||||
Reference in new issue
Block a user