Skip to content

Commit 4d9fc2a

Browse files
author
Daniel Ribeiro
authored
Merge pull request #81 from zendesk/daniel/increase-promise-timeout
Increase promise timeout to 10 seconds
2 parents b8180e3 + 81fc76b commit 4d9fc2a

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

lib/client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
var PROMISE_TIMEOUT = 5000
2-
// 5 seconds
1+
var PROMISE_TIMEOUT = 10000
2+
// 10 seconds, see ZD#4058685
33
var PROMISE_DONT_TIMEOUT = ['instances.create']
44
var ZAF_EVENT = /^zaf\./
55
var version = require('version')
@@ -16,7 +16,7 @@ window.Promise = Promise
1616
// #timeoutReject(rejectionFn, name, params)
1717
//
1818
// Reject a request if required, given the rejection function, name (get, set or invoke)
19-
// and arguments to that request. Falls back to 5000 second timeout with few exceptions.
19+
// and arguments to that request. Falls back to 10000 second timeout with few exceptions.
2020
//
2121
function timeoutReject (reject, name, client, paramsArray) {
2222
switch (name) {

spec/client_spec.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ describe('Client', function () {
55
var Tracking = require('../lib/tracking')
66
var Tracker = Tracking.Tracker
77
var Promise = window.Promise || require('native-promise-only')
8+
var PROMISE_TIMEOUT = 10000
89
var sandbox = sinon.sandbox.create()
910
var origin = 'https://foo.zendesk.com'
1011
var appGuid = 'ABC123'
@@ -571,10 +572,10 @@ describe('Client', function () {
571572
}).to.throw(Error)
572573
})
573574

574-
it('rejects the promise after 5 seconds', function (done) {
575+
it('rejects the promise after 10 seconds', function (done) {
575576
var clock = sinon.useFakeTimers()
576577
promise = subject.get('ticket.subject')
577-
clock.tick(5000)
578+
clock.tick(PROMISE_TIMEOUT)
578579
clock.restore()
579580
expect(promise).to.be.rejectedWith(Error, 'Invocation request timeout').and.notify(done)
580581
})
@@ -659,10 +660,10 @@ describe('Client', function () {
659660
})
660661
})
661662

662-
it('rejects the promise after 5 seconds', function (done) {
663+
it('rejects the promise after 10 seconds', function (done) {
663664
var clock = sinon.useFakeTimers()
664665
promise = subject.set('ticket.subject', 'test')
665-
clock.tick(5000)
666+
clock.tick(PROMISE_TIMEOUT)
666667
clock.restore()
667668
expect(promise).to.be.rejectedWith(Error, 'Invocation request timeout').and.notify(done)
668669
})
@@ -718,18 +719,18 @@ describe('Client', function () {
718719
}).to.throw(Error, 'Invoke supports string arguments or an object with array of strings.')
719720
})
720721

721-
it('rejects the promise after 5 seconds', function (done) {
722+
it('rejects the promise after 10 seconds', function (done) {
722723
var clock = sinon.useFakeTimers()
723724
promise = subject.invoke('ticket.subject', 'test')
724-
clock.tick(5000)
725+
clock.tick(PROMISE_TIMEOUT)
725726
clock.restore()
726727
expect(promise).to.be.rejectedWith(Error, 'Invocation request timeout').and.notify(done)
727728
})
728729

729-
it('doesnt reject whitelisted promises after 5 seconds', function (done) {
730+
it('doesnt reject whitelisted promises after 10 seconds', function (done) {
730731
var clock = sinon.useFakeTimers()
731732
promise = subject.invoke('instances.create')
732-
clock.tick(10000)
733+
clock.tick(15000)
733734
clock.restore()
734735
expect(promise).to.eventually.become({ errors: {}, 'instances.create': { url: 'http://a.b' } }).and.notify(done)
735736
window.addEventListener.callArgWith(1, {

0 commit comments

Comments
 (0)