MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    I possibly found an updateNotification bug that may be responsible for the out of memory errors

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    updatenotification
    13 Posts 3 Posters 3.6k Views 5 Watching
    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.
    • M Offline
      mlcampbe
      last edited by

      Yeah I think I may have jump to a conclusion too fast. In my overnight test I had the updateInterval set to 6hrs so there was no overlap of events firing as I only have 6 modules installed.

      The overnight test did show it adding to the simpleGits array but subsequent testing showed that if I cleared the array as I listed then there were no subsequent updates. That would go along with the fact that the array would only be built 1 time. I am not sure what was going on initially.

      I’ve removed all my added code except the console.log message to see when the updates are called and what modules are updated. I’ll monitor it for a bit and see what happens.

      M 1 Reply Last reply Reply Quote 0
      • M Offline
        mlcampbe @mlcampbe
        last edited by

        @mlcampbe
        I checked my logs this morning and with the updateInterval set to 1hr I see some fishy updates.

        19:05 - checks all 7 modules 2 times
        20:05 - checks all 7 modules 3 times
        21:05 - checks all 7 modules 3 times
        21:32 - checks all 7 modules 3 times
        22:32 - checks all 7 modules 8 times
        0:32 - checks all 7 modules 4 times
        1:32 - checks all 7 modules 4 times

        So there is something odd going on. After I restarted MM via the pm2 process I then access MM via browser on a local machine and it refreshes all modules and I can see that the number of times updateNotification checks the modules gets incremented by 1. Every time I refresh the browser it prints out my modules and clearly this scenario is causing the simpleGits array to be appended to and all modules to be checked n+1 times.

        As a fix I added code to save the incoming module list (passed into socketNotificationReceived) like this:

                socketNotificationReceived: function (notification, payload) {
                        if (notification === "CONFIG") {
                                this.config = payload;
                                savedPayload = payload;
                        } else if(notification === "MODULES") {
                                this.configureModules(payload);
                                this.preformFetch();
                        }
                },
        

        Now the variable savedPayload is re-used at the bottom of the preformFetch:

                                sg.git.fetch().status(function(err, data) {
                                        data.module = sg.module;
                                        if (!err) {
                                                sg.git.log({"-1": null}, function(err, data2) {
                                                        data.hash = data2.latest.hash;
                                                        self.sendSocketNotification("STATUS", data);
                                                });
                                        }
                                });
                        });
                        simpleGits = [];
                        this.configureModules(savedPayload);
                        this.scheduleNextFetch(this.config.updateInterval);
                },
        

        That seems to work for browser refreshes as I can see that no matter how many times I refresh it there is only a single check of each module. I’ll monitor updateInterval refreshes to see what occurs.

        S 2 Replies Last reply Reply Quote 0
        • S Offline
          sdetweil @mlcampbe
          last edited by

          @mlcampbe yes, MM screen refresh causes LOTS of problems… most modules cannot handle this…
          (the MM design is that it should never be done)

          access remote OR local but not both…

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @mlcampbe
            last edited by sdetweil

            @mlcampbe i don’t think u needed to save the payload… i think clearing the array should be enough…

            the payload should be the same, as the module.js is just getting a list of installed/running modules.

            actually a more simple way, is check to see if the timer is not started,. then allow config, else skip it.
            then it will only be done once…

            basically change this

            	socketNotificationReceived: function (notification, payload) {
            		if (notification === "CONFIG") {
            			this.config = payload;
            		} else if(notification === "MODULES") {
            			this.configureModules(payload);
            			this.preformFetch();
            		}
            	},
            

            to this

            	socketNotificationReceived: function (notification, payload) {
            		if (notification === "CONFIG") {
            			this.config = payload;
            		} else if(notification === "MODULES") {
                                  // if refresh cycle timer not yet started
                                  if(this.updateTimer==null ){
            			this.configureModules(payload);
            			this.preformFetch();
                                  }
            		}
            	},
            

            this still leaves a tiny window, if the initial cycle is running, and you start another via refresh…
            so, this calls for another flag.
            updateProcessStarted: false
            and this

            	socketNotificationReceived: function (notification, payload) {
            		if (notification === "CONFIG") {
            			this.config = payload;
            		} else if(notification === "MODULES") {
                                  // if this is the 1st time thru the update check process
                                  if(this.updateProcessStarted==false ){
                                    this.updateProcessStarted=true;
            			this.configureModules(payload);
            			this.preformFetch();
                                  }
            		}
            	},
            

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • M Offline
              mlcampbe
              last edited by

              Sam, when I cleared the simpleGits array only then nothing was refreshing. That could have been where I was clearing it though. It seems that as you mentioned the configureModules was only getting called 1 time when initially loaded unless of course I accessed MM via the browser which called everything again.

              For now I am happy with my solution as it is working for both auto refreshes via the updateInterval and for browser access from another machine. Its not any more code than you added but just done a different way. It may not be quite as efficient as it builds the simpleGits array everytime it is called but I don’t plan to call it more than once every 6 hrs anyway so that is not going to be a problem.

              It is yet to be seen if this fixes the out of memory errors that were being seen though. I’ll have to leave it running for a day or 2 and check to see what happens.

              1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil
                last edited by

                ok, I have mine running too… shows 1 update available…

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • M Offline
                  mlcampbe
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil
                    last edited by

                    I’ve spent the day looking over the module, and there are a number of bugs that had to be fixed.

                    the design is synchronous calls to simple-gits module, but simple-gits uses promises under the covers, so everything is actually async, which exposes some potential data corruption

                    also the module.js overwrites the this.status pointer on each notification from the helper, before checking if the data is useful (behind > 0)… which yanks the data out from under getDom().

                    and getDom() processes for each good data message, overlaying anything prior… only one module status shows

                    i am testing fixes for all of that…

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 1
                    • E Offline
                      ezarlive
                      last edited by

                      Make a pull request ;)

                      S 1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @ezarlive
                        last edited by

                        @ezarlive testing… before sending the code

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 1 / 2
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Sam, technical setup by Karsten.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy