Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    Error on update module

    Bug Hunt
    1
    1
    626
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      soul last edited by soul

      Hi everyone,

      I’m doing a module (display data from Habitica ) .

      I got the following errors but not at every update. I happened like about 1 time every 5 min (i haven’t seen any regular pattern, it can happen several time in 1 minute and nothing for 10 minutes). And the error can be one of the 3 following :

      • Error: read ECONNRESET (or Error: read ETIMEDOUT) at TLSWrap.onread
      • UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘hash’ of null
      • Error: getaddrinfo ENOTFOUND habitica.com

      This is what i have coded :

      • MMM-Habitica.js : updateHabitica => sendSocketNotification(myConfig)
      • node_helper.js : reload() => forEach (members in config.members) => send https request ; on requestResult.end => sendSocketNotification(returnData)
      • MMM-Habitica.js : socketNotificationReceived => gather data and construct dom object

      Does anybody has a clue about what could go wrong? (https request with forEach, wrong data from api, other? )

      Any help would be greatly welcome

      Guillaume

      **UPDATE : ** 🕺🏻
      It seems enclosing the https request in a promise resolve the issue no error so far

      return new Promise((resolve, reject) => {
      
                  var req = https.request(requestOptions, (res) => {
                      res.setEncoding('utf8');
                      res.on('data', (chunk) => {
                          try{
                              JSONParsed = JSON.parse(chunk);
                          }catch(error) {
                          }
                      });
      
                      res.on('end', () => {
                          self.sendSocketNotification(reloadType, JSONParsed);
                      });
      
                      req.on('error', (e) => {
                          console.log(`problem with request: ${e.message}`);
                      });
      
                  });
      
                  req.end();
              })
      
      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy