Browse Source

make tokens last a bit longer

session-estimator
Mathias Buus 4 years ago
parent
commit
02a78f3a83
  1. 8
      lib/io.js

8
lib/io.js

@ -26,7 +26,7 @@ module.exports = class IO {
this.ontimeout = ontimeout this.ontimeout = ontimeout
this._pending = new FIFO() this._pending = new FIFO()
this._rotateSecrets = 8 this._rotateSecrets = 10
this._tid = (Math.random() * 65536) | 0 this._tid = (Math.random() * 65536) | 0
this._secrets = null this._secrets = null
this._drainInterval = null this._drainInterval = null
@ -65,6 +65,8 @@ module.exports = class IO {
if (i === this.inflight.length - 1) this.inflight.pop() if (i === this.inflight.length - 1) this.inflight.pop()
else this.inflight[i] = this.inflight.pop() else this.inflight[i] = this.inflight.pop()
// TODO: Auto retry here if BAD_TOKEN is returned?
if (req._timeout) { if (req._timeout) {
clearTimeout(req._timeout) clearTimeout(req._timeout)
req._timeout = null req._timeout = null
@ -161,7 +163,7 @@ module.exports = class IO {
_drain () { _drain () {
if (this._secrets !== null && --this._rotateSecrets === 0) { if (this._secrets !== null && --this._rotateSecrets === 0) {
this._rotateSecrets = 8 this._rotateSecrets = 10
const tmp = this._secrets[0] const tmp = this._secrets[0]
this._secrets[0] = this._secrets[1] this._secrets[0] = this._secrets[1]
this._secrets[1] = tmp this._secrets[1] = tmp
@ -237,7 +239,7 @@ class Request {
} }
error (code, opts = {}) { error (code, opts = {}) {
this.sendReply(code, null, false, this.target !== null && opts.closerNodes !== false) this.sendReply(code, null, opts.token === true, this.target !== null && opts.closerNodes !== false)
} }
send (force = false) { send (force = false) {

Loading…
Cancel
Save