Monday, 12 June 2017

WebSocket emit waits for task to finish / how to force emit

I am running a heavy task on my Node.js server and want to give status updates to the user via node.js. The heavy task basically consists of looping through huge arrays with n^3 runtime complexity, so I think it's blocking.

I use socket.io together with express in a POST request which uploads a file that then gets processed. While processing, in the for-loop I call io.emit('event', progress)but all the emits are only being received by the client after the process has finished. How can I force the emits to be sent instead of them waiting for the heavy task to finish?

Thank you very much!



via Maximilian Böther

No comments:

Post a Comment