tus / tus/tus-node-server

onUploadFinish error throw not being returned to client

Open
#380 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.1k
Forks
228
Avg merge
5m
Merged PRs (30d)
1

Description

Hi,

Not sure if I'm missing something. I tried a simple server:

`'use strict'

import {Server} from '@tus/server';
import {FileStore} from '@tus/file-store';

const host = '127.0.0.1'
const port = 1080
const server = new Server({
path: '/uploads',
datastore: new FileStore({directory: './uploads'}),
async onUploadFinish(req, res, upload) {
throw {body: 'no', status_code: 500};
return res;
}
})

server.listen({host, port})`

And when I try with a simple tus client:

`'use strict'

import * as fs from 'node:fs';
import * as tus from 'tus-js-client';

const path = './example.doc';
const file = fs.createReadStream(path);

const options = {
endpoint: 'http://127.0.0.1:1080/uploads/',
metadata: {
filename: 'example.doc',
filetype: 'application/msword',
description: 'scooby doobie doo'
},
onError (error) {
console.error('An error occurred:')
console.error(error)
process.exitCode = 1
},
onProgress (bytesUploaded, bytesTotal) {
const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2)
console.log(bytesUploaded, bytesTotal, ${percentage}%)
},
onSuccess () {
console.log('Upload finished:', upload.url)
},
};

const upload = new tus.Upload(file, options);
upload.start();`

The upload completes without error.

node ./tus-client.js
0 3690496 0.00%
65536 3690496 1.78%
3690496 3690496 100.00%
Upload finished: http://127.0.0.1:1080/uploads/b21c2577eee60411d30b9edc01d7b4ff

Any help would be appreciated!

thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Server onUploadFinish entry point and trace how a thrown error is handled after the upload completes. Reproduce the behavior with the server and tus client snippets in the issue, then verify that the client receives the callback's failure response instead of a successful upload.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.