Skip to content

Commit

Permalink
@uppy/xhr-upload: fix Timed out waiting for socket
Browse files Browse the repository at this point in the history
Fixes: transloadit#3640
Co-authored-by: Merlijn Vos <[email protected]>
  • Loading branch information
aduh95 and Murderlon committed Oct 19, 2022
1 parent f13580a commit e1915f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/@uppy/aws-s3/src/MiniXHRUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class MiniXHRUpload {
this.uploaderEvents = Object.create(null)
this.i18n = opts.i18n

this.#queueRequestSocketToken = this.requests.wrapPromiseFunction(this.#requestSocketToken)
this.#queueRequestSocketToken = this.requests.wrapPromiseFunction(this.#requestSocketToken, { priority: -1 })
}

#getOptions (file) {
Expand Down Expand Up @@ -280,6 +280,7 @@ export default class MiniXHRUpload {
}

async #uploadRemoteFile (file) {
// TODO: we could rewrite this to use server-sent events instead of creating WebSockets.
try {
if (file.serverToken) {
return this.connectToServerSocket(file)
Expand Down Expand Up @@ -321,6 +322,7 @@ export default class MiniXHRUpload {

this.uppy.emit('upload-success', file, uploadResp)
queuedRequest.done() // eslint-disable-line no-use-before-define
socket.close()
if (this.uploaderEvents[file.id]) {
this.uploaderEvents[file.id].remove()
this.uploaderEvents[file.id] = null
Expand Down
4 changes: 3 additions & 1 deletion packages/@uppy/xhr-upload/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default class XHRUpload extends BasePlugin {
}

this.uploaderEvents = Object.create(null)
this.#queueRequestSocketToken = this.requests.wrapPromiseFunction(this.#requestSocketToken)
this.#queueRequestSocketToken = this.requests.wrapPromiseFunction(this.#requestSocketToken, { priority: -1 })
}

getOptions (file) {
Expand Down Expand Up @@ -377,6 +377,7 @@ export default class XHRUpload extends BasePlugin {
}

async uploadRemote (file) {
// TODO: we could rewrite this to use server-sent events instead of creating WebSockets.
try {
this.uppy.emit('upload-started', file)
if (file.serverToken) {
Expand Down Expand Up @@ -418,6 +419,7 @@ export default class XHRUpload extends BasePlugin {

this.uppy.emit('upload-success', file, uploadResp)
queuedRequest.done() // eslint-disable-line no-use-before-define
socket.close()
if (this.uploaderEvents[file.id]) {
this.uploaderEvents[file.id].remove()
this.uploaderEvents[file.id] = null
Expand Down

0 comments on commit e1915f6

Please sign in to comment.