Skip to content

Conversation

@nsandstrom
Copy link
Contributor

@nsandstrom nsandstrom commented Feb 19, 2025

It currently it looks something like this in the logs whenever an app returns a 404

404 Not found Not Found: / {
  err: Error: Not Found: /
      at _notFound (/Users/nsan/code/kth/node-apps/search-web/server/controllers/systemCtrl.js:53:15)
      at Layer.handle [as handle_request] (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/layer.js:95:5)
      at trim_prefix (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:328:13)
      at /Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:286:9
      at Function.process_params (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:346:12)
      at next (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:280:10)
      at /Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:646:15
      at next (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:265:14)
      at Function.handle (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:175:3)
      at router (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:47:12)
      at Layer.handle [as handle_request] (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/layer.js:95:5)
      at trim_prefix (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:328:13)
      at /Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:286:9
      at Function.process_params (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:346:12)
      at next (/Users/nsan/code/kth/node-apps/search-web/node_modules/express/lib/router/index.js:280:10)
      at /Users/nsan/code/kth/node-apps/search-web/node_modules/express-rate-limit/dist/index.cjs:591:9 {
    status: 404
  }
}

Feels a bit overkill, and the traces will probably always originate from the same line in systemCtrl.js

The sad part. I decided to keep the message as log.info(´404 Not found ${err.message}´) to match the other cases.
But all (or at least most) apps also includes "Not Found" when the error is crated, so the final message now will be something like 404 Not found Not Found: /.
Feels like a minor inconvenience though.

@nsandstrom nsandstrom force-pushed the feat/do-not-log-stacktrace-on-404 branch from b5220dd to 45f9909 Compare February 19, 2025 13:57
@nsandstrom nsandstrom requested a review from a team as a code owner February 19, 2025 13:57
@nsandstrom nsandstrom requested review from AnnaClasson, Rogiervdw, ahrsjo, falric, hanifb1360, mthege and perlan and removed request for a team February 19, 2025 13:57
Copy link

@ahrsjo ahrsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

giphy

Copy link
Contributor

@falric falric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Nice.

@nsandstrom nsandstrom merged commit 8d09e89 into main Feb 21, 2025
3 checks passed
@nsandstrom nsandstrom deleted the feat/do-not-log-stacktrace-on-404 branch February 21, 2025 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants