I noticed that in the Node.js implementation, even if the client closes the connection, the setInterval function will continue running. I made an edit so it handles connection closures:
let eventInterval = setInterval(() => { res.write(`data: ${JSON.stringify(getData())}\n\n`) }, 2000) req.on('close', (err) => { clearInterval(eventInterval); res.end(); })
Perfect, thanks, I updated the source code on GitHub
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I noticed that in the Node.js implementation, even if the client closes the connection, the setInterval function will continue running. I made an edit so it handles connection closures:
Perfect, thanks, I updated the source code on GitHub