Description
In api_usage.js Log.create(...) is called without await and without a .catch() handler. If the MongoDB write throws (e.g., validation error, connection drop), Node.js emits an UnhandledPromiseRejection. In Node 18+, this terminates the process. A secondary issue: ApiAnalytics.create(...) inside setImmediate similarly has no per-call rejection guard — only a broad console.error.
Steps to Reproduce
- Start public-api with NODE_ENV=development.
- Drop or saturate the MongoDB connection while making any API call.
- Observe that the logger's fire-and-forget Log.create() emits an UnhandledPromiseRejection.
- On Node 18+, the process exits unexpectedly.
Expected Behaviour
Logging failures should be silently swallowed (or re-routed to a fallback) without crashing or interrupting the request/response cycle.
Actual Behaviour
Log.create({...}) is called without .catch(). Any thrown error propagates as an unhandled rejection and can terminate the Node.js process.
Description
In api_usage.js Log.create(...) is called without await and without a .catch() handler. If the MongoDB write throws (e.g., validation error, connection drop), Node.js emits an UnhandledPromiseRejection. In Node 18+, this terminates the process. A secondary issue: ApiAnalytics.create(...) inside setImmediate similarly has no per-call rejection guard — only a broad console.error.
Steps to Reproduce
Expected Behaviour
Logging failures should be silently swallowed (or re-routed to a fallback) without crashing or interrupting the request/response cycle.
Actual Behaviour
Log.create({...}) is called without .catch(). Any thrown error propagates as an unhandled rejection and can terminate the Node.js process.