瀏覽代碼

tus: remove `autoRetry` option (#2938)

Antoine du Hamel 3 年之前
父節點
當前提交
62a722be80

+ 1 - 1
BACKLOG.md

@@ -56,7 +56,7 @@ PRs are welcome! Please do open an issue to discuss first if it's a big feature,
 - [ ] xhr: set the `limit` option to a sensible default, like 5 (10?) (@arturi)
 - [x] xhr: change default name depending on whether `bundle` is set `files[]` (`true`) vs `file` (default) (#782) (@aduh95)
 - [ ] providers: allow changing provider name title through locale? https://github.com/transloadit/uppy/issues/2279 (@goto-bus-stop)
-- [ ] tus: remove `autoRetry` option (throw error at runtime if it is explicitly given) (@aduh95)
+- [x] tus: remove `autoRetry` option (throw error at runtime if it is explicitly given) (@aduh95)
 
 ---
 

+ 0 - 1
packages/@uppy/tus/README.md

@@ -19,7 +19,6 @@ const uppy = new Uppy()
 uppy.use(Tus, {
   endpoint: 'https://tusd.tusdemo.net/files/', // use your tus endpoint here
   resume: true,
-  autoRetry: true,
   retryDelays: [0, 1000, 3000, 5000]
 })
 ```

+ 4 - 9
packages/@uppy/tus/src/index.js

@@ -66,7 +66,6 @@ module.exports = class Tus extends Plugin {
 
     // set default options
     const defaultOptions = {
-      autoRetry: true,
       resume: true,
       useFastRemoteRetry: true,
       limit: 0,
@@ -78,6 +77,10 @@ module.exports = class Tus extends Plugin {
     /** @type {import("..").TusOptions} */
     this.opts = { ...defaultOptions, ...opts }
 
+    if ('autoRetry' in opts) {
+      throw new Error('The `autoRetry` option was deprecated and has been removed.')
+    }
+
     /**
      * Simultaneous upload limiting is shared across all uploads with this plugin.
      *
@@ -695,10 +698,6 @@ module.exports = class Tus extends Plugin {
     this.uppy.addUploader(this.handleUpload)
 
     this.uppy.on('reset-progress', this.handleResetProgress)
-
-    if (this.opts.autoRetry) {
-      this.uppy.on('back-online', this.uppy.retryAll)
-    }
   }
 
   uninstall () {
@@ -706,9 +705,5 @@ module.exports = class Tus extends Plugin {
       capabilities: { ...this.uppy.getState().capabilities, resumableUploads: false },
     })
     this.uppy.removeUploader(this.handleUpload)
-
-    if (this.opts.autoRetry) {
-      this.uppy.off('back-online', this.uppy.retryAll)
-    }
   }
 }

+ 28 - 0
packages/@uppy/tus/src/index.test.js

@@ -0,0 +1,28 @@
+const Core = require('@uppy/core')
+const Tus = require('.')
+
+describe('Tus', () => {
+  it('Throws errors if autoRetry option is true', () => {
+    const uppy = new Core()
+
+    expect(() => {
+      uppy.use(Tus, { autoRetry: true })
+    }).toThrowError(/The `autoRetry` option was deprecated and has been removed/)
+  })
+
+  it('Throws errors if autoRetry option is false', () => {
+    const uppy = new Core()
+
+    expect(() => {
+      uppy.use(Tus, { autoRetry: false })
+    }).toThrowError(/The `autoRetry` option was deprecated and has been removed/)
+  })
+
+  it('Throws errors if autoRetry option is `undefined`', () => {
+    const uppy = new Core()
+
+    expect(() => {
+      uppy.use(Tus, { autoRetry: undefined })
+    }).toThrowError(/The `autoRetry` option was deprecated and has been removed/)
+  })
+})

+ 0 - 1
packages/@uppy/tus/types/index.d.ts

@@ -15,7 +15,6 @@ declare module Tus {
 
   export interface TusOptions extends Uppy.PluginOptions, TusUploadOptions {
     metaFields?: string[] | null
-    autoRetry?: boolean
     limit?: number
     useFastRemoteRetry?: boolean
     withCredentials?: boolean