|
@@ -126,6 +126,8 @@ module.exports = class XHRUpload extends Plugin {
|
|
|
createProgressTimeout (timeout, timeoutHandler) {
|
|
|
const uppy = this.uppy
|
|
|
const self = this
|
|
|
+ let isDone = false
|
|
|
+
|
|
|
function onTimedOut () {
|
|
|
uppy.log(`[XHRUpload] timed out`)
|
|
|
const error = new Error(self.i18n('timedOut', { seconds: Math.ceil(timeout / 1000) }))
|
|
@@ -134,17 +136,24 @@ module.exports = class XHRUpload extends Plugin {
|
|
|
|
|
|
let aliveTimer = null
|
|
|
function progress () {
|
|
|
+ // Some browsers fire another progress event when the upload is
|
|
|
+ // cancelled, so we have to ignore progress after the timer was
|
|
|
+ // told to stop.
|
|
|
+ if (isDone) return
|
|
|
+
|
|
|
if (timeout > 0) {
|
|
|
- done()
|
|
|
+ if (aliveTimer) clearTimeout(aliveTimer)
|
|
|
aliveTimer = setTimeout(onTimedOut, timeout)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function done () {
|
|
|
+ uppy.log(`[XHRUpload] timer done`)
|
|
|
if (aliveTimer) {
|
|
|
clearTimeout(aliveTimer)
|
|
|
aliveTimer = null
|
|
|
}
|
|
|
+ isDone = true
|
|
|
}
|
|
|
|
|
|
return {
|