Fix safeFetch metrics double-counting failed requests #15

Closed
opened 2026-05-17 12:06:01 +00:00 by MrSphay · 2 comments
Owner

Created from local project scan after reviewing existing issues #1-#13.

Current status: pis/utils/fetch.mjs records a failed metric before throwing on non-2xx responses, then records another failed metric in the catch block for the same request. HTML responses after a 200 are also counted once as OK and then again as failed. This can inflate /api/metrics failure/request counts and make source reliability look worse or inconsistent.

Code references:

  • pis/utils/fetch.mjs: safeFetch() records HTTP failures around lines 56 and 69.
  • pis/utils/fetch.mjs: HTML-as-JSON failures are recorded as OK around line 60, then as failed around line 69.

Acceptance criteria:

  • Each network attempt contributes exactly one metric record.
  • Non-2xx responses preserve status, body byte count, duration, and error text without double counting.
  • HTML/non-JSON responses are recorded as failed JSON-shape errors, not successful fetches.
  • Add regression tests covering HTTP failure, HTML response, and retry behavior.
Created from local project scan after reviewing existing issues #1-#13. Current status: pis/utils/fetch.mjs records a failed metric before throwing on non-2xx responses, then records another failed metric in the catch block for the same request. HTML responses after a 200 are also counted once as OK and then again as failed. This can inflate /api/metrics failure/request counts and make source reliability look worse or inconsistent. Code references: - pis/utils/fetch.mjs: safeFetch() records HTTP failures around lines 56 and 69. - pis/utils/fetch.mjs: HTML-as-JSON failures are recorded as OK around line 60, then as failed around line 69. Acceptance criteria: - Each network attempt contributes exactly one metric record. - Non-2xx responses preserve status, body byte count, duration, and error text without double counting. - HTML/non-JSON responses are recorded as failed JSON-shape errors, not successful fetches. - Add regression tests covering HTTP failure, HTML response, and retry behavior.
Author
Owner

In Bearbeitung durch Codex auf Branch codex/issue-15-fetch-metrics. Scope: safeFetch Metrics-Doppelzaehlung: pro Attempt genau ein Metric Record, HTTP/HTML Fehler korrekt als failed, Regressionstests. Runner-only: keine lokalen npm/node Laeufe.

In Bearbeitung durch Codex auf Branch codex/issue-15-fetch-metrics. Scope: safeFetch Metrics-Doppelzaehlung: pro Attempt genau ein Metric Record, HTTP/HTML Fehler korrekt als failed, Regressionstests. Runner-only: keine lokalen npm/node Laeufe.
Author
Owner

PR geoeffnet: #33\n\nStatus: mergeable. Scope: safeFetch/safeFetchText zaehlen pro Attempt genau einen Metric Record; HTTP- und HTML/JSON-Shape-Fehler behalten Status/Bytes/Error ohne Doppelzaehlung. Regressionen fuer HTTP failure, HTML response und Retry-Accounting ergaenzt. Runner-only: keine lokalen npm/node Tests.

PR geoeffnet: https://git.wilkensxl.de/MrSphay/intelligence-terminal/pulls/33\n\nStatus: mergeable. Scope: safeFetch/safeFetchText zaehlen pro Attempt genau einen Metric Record; HTTP- und HTML/JSON-Shape-Fehler behalten Status/Bytes/Error ohne Doppelzaehlung. Regressionen fuer HTTP failure, HTML response und Retry-Accounting ergaenzt. Runner-only: keine lokalen npm/node Tests.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: MrSphay/intelligence-terminal#15