From 91f99405c12273332dafccb25a10e2796d5517b6 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Mon, 16 Mar 2026 20:51:33 -0700 Subject: [PATCH] fix(logs): Reducing log noise --- dev-docs/update-logs/2026-03-16.md | 21 +++++++++++++++++++++ src/controllers/rest-api/slp/controller.js | 9 ++++++++- src/use-cases/slp-use-cases.js | 9 ++++++++- 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 dev-docs/update-logs/2026-03-16.md diff --git a/dev-docs/update-logs/2026-03-16.md b/dev-docs/update-logs/2026-03-16.md new file mode 100644 index 0000000..fa1bf66 --- /dev/null +++ b/dev-docs/update-logs/2026-03-16.md @@ -0,0 +1,21 @@ +# 2026-03-16 Update Log + +## Summary + +Reduced noisy error logging for common SLP transaction misses in the `/v6/slp/txid` path. + +## Changes Made + +- Updated `src/use-cases/slp-use-cases.js` in `getTxid()`: + - Added a guard for expected missing-record errors (`404` + `Key not found in database`). + - Skips `wlogger.error()` for that specific, common case. + - Still rethrows the error so API response behavior is unchanged. +- Updated `src/controllers/rest-api/slp/controller.js` in `handleError()`: + - Added the same guard to suppress duplicate error-level logs for the same expected case. + - Keeps normal error logging for all other errors. + +## Outcome + +- The common "Key not found in database" case no longer pollutes error logs. +- Unexpected failures continue to be logged at error level. +- Client-facing status and error message behavior remains unchanged. diff --git a/src/controllers/rest-api/slp/controller.js b/src/controllers/rest-api/slp/controller.js index a5837e0..4698720 100644 --- a/src/controllers/rest-api/slp/controller.js +++ b/src/controllers/rest-api/slp/controller.js @@ -208,7 +208,14 @@ class SlpRESTController { } handleError (err, res) { - wlogger.error('Error in SlpRESTController:', err) + const isCommonMissingTxError = + err?.status === 404 && + typeof err?.message === 'string' && + err.message.includes('Key not found in database') + + if (!isCommonMissingTxError) { + wlogger.error('Error in SlpRESTController:', err) + } const status = err.status || 500 const message = err.message || 'Internal server error' diff --git a/src/use-cases/slp-use-cases.js b/src/use-cases/slp-use-cases.js index 406f7ce..f528f82 100644 --- a/src/use-cases/slp-use-cases.js +++ b/src/use-cases/slp-use-cases.js @@ -98,7 +98,14 @@ class SlpUseCases { try { return await this.slpIndexer.post('slp/tx/', { txid }) } catch (err) { - wlogger.error('Error in SlpUseCases.getTxid()', err) + const isCommonMissingTxError = + err?.status === 404 && + typeof err?.message === 'string' && + err.message.includes('Key not found in database') + + if (!isCommonMissingTxError) { + wlogger.error('Error in SlpUseCases.getTxid()', err) + } throw err } }