Uppy says upload to Transloadit failed but it succeeded

Hi,

I’m not sure if this is a usage problem or perhaps a bug in uppy or one of the plugins.

I’m using Uppy with Transloadit and programmatically uploading two files to a single assembly. Everything works except Uppy mistakenly thinks the uploads are failing when they are actually succeeding.

The error message appears to come from the Tus plugin and it seems to be due to the assembly being further along than expected.

This error appears in the console:

tus: unexpected response while creating upload, originated from request (method: POST, url: https://api2-ferraz.transloadit.com/resumable/files/, response code: 400, response text: {\"error\":\"Assembly 5310b6f516da4cf4902eb8428d6a2b7a is not in ASSEMBLY_UPLOADING state (instead ASSEMBLY_EXECUTING)\"})\n, request id: 28cd124f-5bfa-4b9a-af4d-17d748b79199

And the uppy complete event always fires with both files in failed and none in successful, but both files do upload and the assembly completes successfully.

Here is a small example to reproduce:

// "@uppy/core": "^1.12.2",
// "@uppy/react": "^1.10.2",
// "@uppy/transloadit": "^1.6.5",
// "@uppy/tus": "^1.7.3",

const id = 'image'; // there is another uploader on the page with id video
const uppy = new Uppy({id, debug: true});
const params = {/*transloadit params*/};
const fields = [/*meta field names*/];
uppy.use(Transloadit, {
  params,
  fields,
  waitForEncoding: false, // tried with true to no avail
  waitForMetadata: false, // tried with true to no avail
});
uppy.addFile(watermarkFile);
uppy.addFile(imageFile);
const meta = {/*metadata*/};
uppy.setMeta({
  ...meta,
  watermark: watermarkFile,
  image: imageFile
});
uppy.once('transloadit:assembly-created', (assembly) => {
  // this works
  console.log(assembly);
});
uppy.once('complete', ({successful, failed}) => {
  // this always has both files in "failed" despite them uploading successfully and the assembly completing successfully
  console.log(successful, failed);
  if (failed.length) {
    alert('failed');
  }
});
uppy.upload();

Any ideas appreciated!

Here’s another instance of the same issue, this time with some more context around the error message:

[Uppy] [14:23:43] Added file: overlay.png, uppy-overlay/png-1e-image/png-34899, mime type: image/png
[Uppy] [14:23:43] Added file: noname, uppy-application/octet-stream-6539143-1597082484672, mime type: application/octet-stream
[Uppy] [14:23:43] Adding metadata:
[Uppy] [14:23:43]
Object { width: 1080, height: 1080, artwork_crop_x1: 0, artwork_crop_y1: 0, artwork_crop_x2: 1972, artwork_crop_y2: 1439, artwork_crop_width: 1972, artwork_crop_height: 1439, artwork_width: 1080, artwork_height: 788, … }
[Uppy] [14:23:43] [Transloadit] Create Assembly
XHR OPTIONS https://api2.transloadit.com/assemblies 200 OK
XHR POST https://api2.transloadit.com/assemblies 200 OK
[Uppy] [14:23:49] [Transloadit] Created Assembly be84ce71bb094268b85ce78b93ce4d49
[Uppy] [14:23:49] [Tus] Uploading...
XHR OPTIONS https://api2-sayula.transloadit.com/resumable/files/ 200 OK
XHR OPTIONS https://api2-sayula.transloadit.com/resumable/files/ 200 OK
GET wss://api2-sayula.transloadit.com/... 101 Switching Protocols
XHR POST https://api2-sayula.transloadit.com/resumable/files/ 400 Bad Request
XHR POST https://api2-sayula.transloadit.com/resumable/files/ 400 Bad Request
[Uppy] [14:23:49] [Transloadit] Socket is ready
[Uppy] [14:23:49] Error: tus: unexpected response while creating upload, originated from request (method: POST, url: https://api2-sayula.transloadit.com/resumable/files/, response code: 400, response text: {"error":"Assembly be84ce71bb094268b85ce78b93ce4d49 is not in ASSEMBLY_UPLOADING state (instead ASSEMBLY_EXECUTING)"}), request id: 066f8558-7253-450b-85da-1b99e0b59ac7)
[Uppy] [14:23:49] Error: tus: unexpected response while creating upload, originated from request (method: POST, url: https://api2-sayula.transloadit.com/resumable/files/, response code: 400, response text: {"error":"Assembly be84ce71bb094268b85ce78b93ce4d49 is not in ASSEMBLY_UPLOADING state (instead ASSEMBLY_EXECUTING)"}), request id: ed177653-bd11-4955-b10f-1440a0201231)

I am not sure if this is relevant but it looks like this issue is only occurring for me on files over a certain size (or perhaps that take longer to upload)

I have a couple small ~25KiB files that seem to work fine every time, and a handful of files over 1MB that all show the issue above 100% of the time.