TsimpDim/PassBuy

Server crashing due to un-handled error?!

iamaldi opened this issue · 5 comments

The server log contains an error message:

^Bevents.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Connection lost: The server closed the connection.
    at Protocol.end (/home/redacted/the-dream-team/back-end/api/node_modules/mysql/lib/protocol/Protocol.js:113:13)
    at Socket.<anonymous> (/home/redacted/the-dream-team/back-end/api/node_modules/mysql/lib/Connection.js:109:28)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Notice the throw er; error. Looks like a typo somewhere in the code.

Το error είναι πιθανότατα επειδή αυτή τη στιγμή έχουμε μια μόνο σύνδεση που μοιράζονται όλοι, την οποία το mysql module τερματίζει μετά από πολλή ώρα αδράνειας.

Μάλλον πρέπει να στραφούμε σε connection pools τα οποία είναι επί της ουσίας "connections on demand" και είναι αρκετά εύκολα να ενσωματωθούν/υλοποιηθούν στον κώδικα μας.

Έχω παρατηρήσει και άλλες λύσεις τύπου "ας κάνουμε force το mysql να κρατήσει τη συνδεση ανοιχτή χτυπώντας sql αιτήματα κάθε xy χρονικά διαστήματα" αλλά είναι πολύ hacky λύση

Typo δεν είναι γιατί δεν είναι σε δικό μας αρχείο αλλά του node :)

@TsimpDim I can confirm that the unavailability of the database service raises an error.