Fix connection resets and heartbeat errors#157
Conversation
… connections and refactoring API routes This commit addresses the reported `read ECONNRESET` and heartbeat errors by: 1. Adding pool-level error handling to the MySQL database controller. 2. Adding error and shardError listeners to the Discord client. 3. Refactoring all major API routes to use async/await with Promises for database queries, ensuring proper response flow control and preventing 'Reply already sent' errors. 4. Cleaning up redundant imports in app.js. 5. Updating common API helpers to return status and be used more robustly in routes. 6. Using parameterized SQL queries in several locations to improve security. Co-authored-by: benrobson <15405528+benrobson@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This commit addresses the reported `read ECONNRESET` and heartbeat errors by: 1. Adding pool-level error handling to the MySQL database controller. 2. Adding error and shardError listeners to the Discord client. 3. Refactoring all major API routes to use async/await with Promises for database queries, ensuring proper response flow control and preventing 'Reply already sent' errors. 4. Cleaning up redundant imports in app.js. 5. Updating common API helpers to return status and be used more robustly in routes. 6. Using parameterized SQL queries in several locations to improve security. 7. Merged the latest changes from `staging` into this branch. Co-authored-by: benrobson <15405528+benrobson@users.noreply.github.com>
… connections and refactoring all API routes This commit addresses the reported `read ECONNRESET` and heartbeat errors by: 1. Adding pool-level error handling to the MySQL database controller. 2. Adding error and shardError listeners to the Discord client. 3. Refactoring ALL major API routes and internal redirect routes to use async/await with Promises for database queries, ensuring proper response flow control and preventing 'Reply already sent' errors. 4. Cleaning up redundant imports in app.js and ensuring 'features' are correctly passed to all route registration functions. 5. Updating common API helpers to return status and be used more robustly in routes. 6. Using parameterized SQL queries in several locations to improve security. 7. Merged latest changes from staging. Co-authored-by: benrobson <15405528+benrobson@users.noreply.github.com>
This commit specifically addresses the `ER_TRUNCATED_WRONG_VALUE` error observed when updating the `serverStatus` table. Incoming ISO datetime strings (potentially with nanosecond precision) are now parsed into JavaScript `Date` objects before being passed to the MySQL driver, ensuring compatible formatting and preventing query failures. Additional stability improvements from the previous refactor are also maintained. Co-authored-by: benrobson <15405528+benrobson@users.noreply.github.com>
This commit further stabilizes the application by: 1. Updating the global error handler in `app.js` to return JSON responses for all routes starting with `/api/`, preventing HTML error pages from being sent to API clients (like cron jobs). 2. Adding a safety guard to the `preHandler` hook in `app.js` to ensure it only attempts to access `req.session` when it exists, preventing crashes on early API or heartbeat routes. 3. Maintaining previous stability fixes for ECONNRESET, heartbeat errors, and datetime truncation. Co-authored-by: benrobson <15405528+benrobson@users.noreply.github.com>
The application was suffering from instability manifested as
read ECONNRESETerrors and Discord heartbeat failures. Investigation revealed that the API routes (which the website calls recursively viafetch) were using a buggy callback pattern that often led to multiple response attempts or hanging requests, overwhelming the server and the MySQL connection pool.This PR fixes these issues by:
app.jsthat could cause multiple module initializations.PR created automatically by Jules for task 17554862004116618049 started by @benrobson