Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert reconnect optimizations which introduced regressions #3272

Merged
merged 1 commit into from Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 2 additions & 25 deletions assets/js/phoenix.js
Expand Up @@ -840,7 +840,6 @@ export class Socket {
this.flushSendBuffer()
this.reconnectTimer.reset()
this.resetHeartbeat()
this.resetChannelTimers()
this.stateChangeCallbacks.open.forEach( callback => callback() )
}

Expand Down Expand Up @@ -989,15 +988,6 @@ export class Socket {
}
})
}

/**
* @private
*/
resetChannelTimers() {
this.channels.forEach(channel => {
channel.rejoinTimer.restart()
})
}
}


Expand Down Expand Up @@ -1358,31 +1348,18 @@ class Timer {

reset(){
this.tries = 0
this.clearTimer()
}

restart(){
const processing = this.timer !== null
this.reset()
if (processing){
this.scheduleTimeout()
}
clearTimeout(this.timer)
}

/**
* Cancels any previous scheduleTimeout and schedules callback
*/
scheduleTimeout(){
this.clearTimer()
clearTimeout(this.timer)

this.timer = setTimeout(() => {
this.tries = this.tries + 1
this.callback()
}, this.timerCalc(this.tries + 1))
}

clearTimer() {
clearTimeout(this.timer)
this.timer = null
}
}
19 changes: 0 additions & 19 deletions assets/test/socket_test.js
Expand Up @@ -605,25 +605,6 @@ describe("onConnOpen", () => {
assert.ok(spy.calledOnce)
})

it("resets all channel timers and schedules a timeout if the timer was in progress", () => {
const channel = socket.channel("topic", {})
const channel2 = socket.channel("topic2", {})

channel.rejoinTimer.tries = 1
channel2.rejoinTimer.tries = 2
channel2.rejoinTimer.scheduleTimeout()

assert.equal(channel.rejoinTimer.timer, null)
assert.notEqual(channel2.rejoinTimer.timer, null)

socket.onConnOpen()

assert.equal(channel.rejoinTimer.tries, 0)
assert.equal(channel2.rejoinTimer.tries, 0)
assert.equal(channel.rejoinTimer.timer, null)
assert.notEqual(channel2.rejoinTimer.timer, null)
})

it("triggers onOpen callback", () => {
const spy = sinon.spy()

Expand Down