I was spending some time trying to get file uploading done with NestJS/Fastify/Tus/Uppy. After some struggles I got it to work. Files get uploaded fine, but always returns the above error. So far I tried uploading very small files upto around 20MB. All gets uploaded and files are not corrupted either.
In dev tools what it shows is something like below
Seems like, it tries to upload a chunk, fails for some reason but manages to upload it again which goes fine.
The stack trace is below
"TypeError: Cannot read properties of undefined (reading ‘write’)\n at PatchHandler.send (D:\Projects\Streamline\streamline\node_modules\@tus\server\dist\handlers\PatchHandler.js:101:44)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async DashboardController.uploadChunk
my nestJS controller has two methods like below(Note I had to remove some NestJS specific syntax (using @) here because editor complained)
All(‘upload’)
async upload(Req() req:Request, Res() res:Response) {
return await this.tusService.handleTus(req, res);
}
All(‘upload/*’)
async uploadChunk(Req() req:Request, Res() res:Response) {
return await this.tusService.handleTus(req, res);
}
Having one method like upload/* doesn’t work. So i had to add /upload endpoint and /upload/* both. That is why I have two methods here.
What may be the issue?