UnWanted reset of flow context

I'm working on a dashboard panel visible below and at http://demo.sunshare.fr
The flow variables sometimes disappear for an unidentified reason. It began while working on a template node. The dashboard become empty.

Does someone have an idea ? What could empty the flow context ? I feel lost. It worked for the last 10 days.
My flow manages 10 flow variables (objects) including 2 "big" tables of ~ 200 values.
Thanks for your help. Julien.

Without seeing your flow, all anyone could do is guess. My guess is that something is wrong somewhere in your flow.

If would help to know

  • version of NR
  • version of node.js
  • version of the dashboard
  • platform you are running on
  • os you are using
  • extra nodes you have installed (i. node-red-contrib-???)
  • and of course your flow

In addition to Paul's post, are you using persistent context, and is there a chance your node-red/device restarted in between? If you're not using persistent context, the flow context lives in the memory of node-red and is cleared/cleaned upon a restart. A restart can also be the result of a crash.

I'm going to assume that this is code you added in a template node:

var home = new Object();
home.payload = 'Home'; // This is the payload that goes out
var theScope = scope;
var clockInterval;
$(function () {
    if (clockInterval) return;
    // add clock

    var divClock = $('<div ></div>');
    var p = $('<p ></p>');
    divClock[0].style.margin = '15px';
    function addZero(i) {
        if (i < 10) {
            i = "0" + i
        return i;

    function formatDate(date) {
        var monthNames = ["Jan.", "Fév.", "Mar.", "Avr.", "Mai", "Juin", "Juil.", "Août", "Sept", "Oct.", "Nov.", "Déc."];
        var day = date.getDate();
        var monthIndex = date.getMonth();
        var year = date.getFullYear();
        var hour = addZero(date.getHours());
        var minute = addZero(date.getMinutes());
        var second = addZero(date.getSeconds());
        return day + ' ' + monthNames[monthIndex] + ' ' + year + " - " + hour +':' + minute ;  // + ':' + second ;
    function displayTime() {
        p.text( formatDate( new Date() ) );
    clockInterval = setInterval(displayTime, 1000);
    // add Text

    var divText = $('<div ></div>');
    var t = document.createTextNode("Boxénergie démo - SunShare"); // <== add title here
    divText[0].style.margin = '40px auto';
    divText[0].style.size = '40';
    // add button

    //var divButton = $('<div ></div>');
    //var button = document.createElement("BUTTON");
    //var b = document.createTextNode("Home Screen")
    //button.addEventListener("click", doIT.bind(null,home));
    // Add picture button
    //var divPicButton = $('<div ></div>');
    //var btn_Home = document.createElement("BUTTON");
    //btn_Home.setAttribute("class", "btnHome_class");
    //var pic = new Image();
    //pic.src = 'http://sunshare.fr/assets/images/SnSr_maison.png'; // <== add path and filename of picture here
    //pic.addEventListener("click", doThis.bind(null,home));
    var addToToolbarTimer;
    function addToToolbar() {
        var toolbar = $('.md-toolbar-tools');
        if(!toolbar.length) return;
        // toolbar.append(divButton);
    addToToolbarTimer = setInterval(addToToolbar, 100);
    function doIT(m){
        theScope.send( m )

    function doThis(m){
        theScope.send( m )


When opening the link from your first post, the browser will run into problems executing it on the toolbar.append(divPicButton) line. This is caused by the whole code defining divPicButton being commented out. I'd say to start there with looking into your issue. That function addToToolbar gets executed every 0.1 seconds, and because it stops working on the append divPicButton line the clearInterval never happens, so it keeps doing that until eternity.

thanks @afelix ! I've deleted tis clock and one of my 2 Rpi's is back. I'll try to inform @harterhorst abouh his NewHeader.

I'll also follow @zenofmud recommandations and update my Rpi's. The first one is deeply crashed as I can't come back to nodered after restart.

Thanks to you both. Regards.

The issues wasn’t with their code, but that you only commented out part of it, thus causing the interval to be repeated.