typeError: can`t read property 'attached' of undefined

Hello. I take this error when i try do refresh columns in datatable. And error appears periodically.
Please, help me fix this.
My code:

function loadVariables(obj, table){
    if (obj && obj.columns && obj.columns.length > 0){
      var variablesTable = $$(table);
      var columns = webix.toArray(variablesTable.config.columns);
      columns.removeAt(1);
      for (let i in obj.columns) {
        if (obj.columns[i].typeTxt) {
          var typeTxt = obj.columns[i].typeTxt['type'];
        }else{
          var typeTxt = '';
        }
        if (obj.columns[i].classTxt) {
          var classTxt = obj.columns[i].classTxt['class'];
        }else{
          var classTxt = 'По умолчанию';
        }
        columns.insertAt({
          id: obj.columns[i].id,
          header: [{
            text: typeTxt,
            css: "multiline-geo"
          },{
            text: classTxt,
            css: "multiline-geo"
          }],
          fillspace: 1,
          editor: "text"
        }, columns.length - 1);
        variablesTable.refreshColumns();
        variablesTable.refresh();
      }
      if (obj.rows){
        for (let i in obj.rows){
          variablesTable.updateItem(obj.rows[i].option_id, obj.rows[i]);
        }
      }
    }
  }

Haw i use:

      let editzeozonevalue = $$('pgeozone_form').getValues();
      let config = [
        { id: "id", hidden: true },
        { id: "name", header: "Название", width: 200 },
        { id: "type0class0", header: { text: "По умолчанию", css: "multiline-geo" }, width: 99, editor: "text" },
        { id: "addNewCol", header: "<button class='webix_button webixtype_base addNewCol' style='background-color:#fec316; margin-top:10px;width:40px;'><span class='webix_icon fa-plus'></span></button>", width: 80 }
      ]
      $$('variablesDatatable').refreshColumns(config);
      loadVariables(editzeozonevalue, "variablesDatatable");

Hello,

Could you please send the code in the snippet to see the problem