Skip to content

Commit

Permalink
tidy up polling code
Browse files Browse the repository at this point in the history
  • Loading branch information
daniep01 committed Aug 17, 2022
1 parent a355763 commit 63d8704
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ instance.prototype.init_tcp = function () {
self.socket.on('error', function (err) {
debug('Network error', err)
self.log('error', 'Network error: ' + err.message)
clearInterval(self.timer)
})

self.socket.on('connect', function () {
Expand Down Expand Up @@ -295,6 +296,11 @@ instance.prototype.config_fields = function () {
instance.prototype.destroy = function () {
var self = this

if (self.timer) {
clearInterval(self.timer)
delete self.timer
}

if (self.socket !== undefined) {
self.socket.destroy()
}
Expand Down

0 comments on commit 63d8704

Please sign in to comment.