There was a standard Node.js assembly (6.9.5) express, socket.io mysql, everything worked, the sockets were sent, everything worked as it should, before installing the Brain, Redis, promise-mysql packages, unknown problems started, and there was a problem with the execution delay actions in 1 step.
Example
On the client, poke Button
on server

socket.on('Card stol', function (data) { console.log(arr); // -> пустой arr.push (data); console.log(arr); //-> пусткой }); 


On the client, poke Button 2 times

 socket.on('Card stol', function (data) { console.log(arr); // -> пустой arr.push (data); console.log(arr); //-> 1 }); 

Maybe someone came across, tried to use promisse, callback, etc. Nothing solves the problem until the assembly has been rebuilt.

 socket.on('Card stol', function (data) { connectionMy.query('SELECT * FROM batle_brain ').then(function(row){ return row; }).then(function(row){ if(row[0] !== 'undefined'){ for(var i = 0 ; i < row.length; i++){ console.log(row[i].h1); // выводит, запрос есть данные есть persipton.push({ input: [row[i].h1, row[i].d1, row[i].b1, row[i].s1,row[i].h2, row[i].d2, row[i].b2, row[i].s2 ], output: [row[i].r] }); console.log(persipton); // пустой на выходе } } console.log(persipton); if(persipton === [] || persipton === 'undefined' || persipton.length === 0 ) { }else { net.train(persipton); var output = net.run([0.003,0.02,0.2,0.1,1,0,0,0]); console.log(output); } }); }); 
  • Frankly, this behavior is hard to believe. arr - normal native array? - vp_arth
  • no, complex massive object - Andrej Larin
  • So, we need its implementation. Specifically interested in the method of push - vp_arth
  • Added, you can see the code - Andrej Larin

0