Closed S0naliThakur closed 3 weeks ago
โฑ๏ธ Estimated effort to review: 3 ๐ต๐ต๐ตโชโช |
๐งช No relevant tests |
๐ No security concerns identified |
โก Key issues to review Possible Memory Leak The `timeoutMiddleware` function sets a timeout using `setTimeout` but does not always clear it if the response is sent before the timeout. This could potentially lead to memory leaks if the `clearTimer` function is not called in all cases where the response is handled. Redundant Code The `customSendJsonMiddleware` function has redundant checks for `res.headersSent` which are already handled in the `res.send` and `res.json` methods. This could be simplified to avoid unnecessary checks and improve code readability. |
This can be done in much simpler way. Please use express's builtin support for this. Something like this is all you need. Example:
const server = app.listen()
server.setTimeout(5000)
Current implementation in PR add unnecessary LOC(s). Please modify.
Linear: https://linear.app/shm/issue/PRI-41 Summary: Added middleware to enforce a timeout on external endpoints, preventing waits beyond a set time limit.