[Bug] public-api: Log.create in api_usage.js is fire-and-forget without error isolation — unhandled rejection can crash the logger
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.
Hi @yash-pouranik ,
I would like to work on this issue under GSSoC 2026.
Could you please assign this issue to me?
Thank you!
Can only assign u to one issue at a time. @Kirtan-pc Choose one from all
Hey @yash-pouranik, You can assign me any issue as I will be working on it one by one only. You can assign me this issue also.
Thank you.
Hey @yash-pouranik, I have resolved this issue and opened a PR, you can review it any time. You can also assign me other issues that I have created as this issue is resolved. Thank you!
Please mention this issue in that PR. @Kirtan-pc
@Kirtan-pc , If the issue is completed you should close it