Socket
Socket
Sign inDemoInstall

@uppy/tus

Package Overview
Dependencies
Maintainers
6
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uppy/tus - npm Package Compare versions

Comparing version 3.0.5 to 3.0.6

8

CHANGELOG.md
# @uppy/tus
## 3.0.6
Released: 2023-04-04
Included in: Uppy v3.7.0
- @uppy/aws-s3-multipart,@uppy/aws-s3,@uppy/tus,@uppy/xhr-upload: make sure that we reset serverToken when an upload fails (Mikael Finstad / #4376)
- @uppy/tus: do not auto-open sockets, clean them up on abort (Antoine du Hamel)
## 3.0.5

@@ -4,0 +12,0 @@

29

lib/index.js

@@ -20,3 +20,3 @@ function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }

const packageJson = {
"version": "3.0.5"
"version": "3.0.6"
};

@@ -514,2 +514,5 @@ /** @typedef {import('..').TusOptions} TusOptions */

// NOTE! Keep this duplicated code in sync with other plugins
// TODO we should probably abstract this into a common function
/**

@@ -528,3 +531,3 @@ * @param {UppyFile} file for use with upload

if (file.serverToken) {
return this.connectToServerSocket(file);
return await this.connectToServerSocket(file);
}

@@ -537,4 +540,7 @@

});
return this.connectToServerSocket(this.uppy.getFile(file.id));
return await this.connectToServerSocket(this.uppy.getFile(file.id));
} catch (err) {
this.uppy.setFileState(file.id, {
serverToken: undefined
});
this.uppy.emit('upload-error', file, err);

@@ -554,3 +560,3 @@ throw err;

connectToServerSocket(file) {
async connectToServerSocket(file) {
var _this2 = this;

@@ -562,3 +568,4 @@

const socket = new Socket({
target: `${host}/api/${token}`
target: `${host}/api/${token}`,
autoOpen: false
});

@@ -584,4 +591,5 @@ this.uploaderSockets[file.id] = socket;

queuedRequest = this.requests.run(() => {
socket.open();
socket.send('resume', {});
return () => {};
return () => socket.close();
});

@@ -616,4 +624,5 @@ }

queuedRequest = this.requests.run(() => {
socket.open();
socket.send('resume', {});
return () => {};
return () => socket.close();
});

@@ -674,3 +683,5 @@ });

socket.send('pause', {});
} // Don't do anything here, the caller will take care of cancelling the upload itself
} else {
socket.open();
} // Just close the socket here, the caller will take care of cancelling the upload itself
// using resetUploaderReferences(). This is because resetUploaderReferences() has to be

@@ -683,3 +694,3 @@ // called when this request is still in the queue, and has not been started yet, too. At

return () => {};
return () => socket.close();
});

@@ -686,0 +697,0 @@ });

{
"name": "@uppy/tus",
"description": "Resumable uploads for Uppy using Tus.io",
"version": "3.0.5",
"version": "3.0.6",
"license": "MIT",

@@ -26,4 +26,4 @@ "main": "lib/index.js",

"dependencies": {
"@uppy/companion-client": "^3.1.0",
"@uppy/utils": "^5.1.0",
"@uppy/companion-client": "^3.1.2",
"@uppy/utils": "^5.2.0",
"tus-js-client": "^3.0.0"

@@ -35,4 +35,4 @@ },

"peerDependencies": {
"@uppy/core": "^3.0.4"
"@uppy/core": "^3.1.2"
}
}

@@ -459,2 +459,4 @@ import BasePlugin from '@uppy/core/lib/BasePlugin.js'

// NOTE! Keep this duplicated code in sync with other plugins
// TODO we should probably abstract this into a common function
/**

@@ -474,3 +476,3 @@ * @param {UppyFile} file for use with upload

if (file.serverToken) {
return this.connectToServerSocket(file)
return await this.connectToServerSocket(file)
}

@@ -482,4 +484,5 @@ const serverToken = await this.#queueRequestSocketToken(file)

this.uppy.setFileState(file.id, { serverToken })
return this.connectToServerSocket(this.uppy.getFile(file.id))
return await this.connectToServerSocket(this.uppy.getFile(file.id))
} catch (err) {
this.uppy.setFileState(file.id, { serverToken: undefined })
this.uppy.emit('upload-error', file, err)

@@ -498,7 +501,7 @@ throw err

*/
connectToServerSocket (file) {
async connectToServerSocket (file) {
return new Promise((resolve, reject) => {
const token = file.serverToken
const host = getSocketHost(file.remote.companionUrl)
const socket = new Socket({ target: `${host}/api/${token}` })
const socket = new Socket({ target: `${host}/api/${token}`, autoOpen: false })
this.uploaderSockets[file.id] = socket

@@ -526,4 +529,6 @@ this.uploaderEvents[file.id] = new EventTracker(this.uppy)

queuedRequest = this.requests.run(() => {
socket.open()
socket.send('resume', {})
return () => {}
return () => socket.close()
})

@@ -553,4 +558,6 @@ }

queuedRequest = this.requests.run(() => {
socket.open()
socket.send('resume', {})
return () => {}
return () => socket.close()
})

@@ -616,5 +623,7 @@ })

socket.send('pause', {})
} else {
socket.open()
}
// Don't do anything here, the caller will take care of cancelling the upload itself
// Just close the socket here, the caller will take care of cancelling the upload itself
// using resetUploaderReferences(). This is because resetUploaderReferences() has to be

@@ -625,3 +634,3 @@ // called when this request is still in the queue, and has not been started yet, too. At

// related to this upload to handle pauses.
return () => {}
return () => socket.close()
})

@@ -628,0 +637,0 @@ })

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc