Do not automatically retry on connection errors!
This commit is contained in:
parent
3a0413d8bb
commit
f5d790b264
@ -170,7 +170,7 @@ function Xo (opts) {
|
|||||||
this._connect()
|
this._connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
Xo.prototype.call = function (method, params) {
|
Xo.prototype.call = function (method, params, retryOnConnectionError) {
|
||||||
// Prevent session.*() from being because it may interfere
|
// Prevent session.*() from being because it may interfere
|
||||||
// with this class session management.
|
// with this class session management.
|
||||||
if (startsWith(method, 'session.')) {
|
if (startsWith(method, 'session.')) {
|
||||||
@ -179,11 +179,19 @@ Xo.prototype.call = function (method, params) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._session.bind(this).then(function () {
|
var this_ = this
|
||||||
return this._api.call(method, params)
|
return this._session.then(function () {
|
||||||
}).catch(ConnectionError, SessionError, function () {
|
return this_._api.call(method, params)
|
||||||
// Automatically requeue this call.
|
}).catch(function (error) {
|
||||||
return this.call(method, params)
|
if (
|
||||||
|
error instanceof SessionError ||
|
||||||
|
retryOnConnectionError && error instanceof ConnectionError
|
||||||
|
) {
|
||||||
|
// Automatically requeue this call.
|
||||||
|
return this_.call(method, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user