Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

onUploadFinish error throw not being returned to client

Aperta
#380 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
nodejs, typescript
Ambito
api, backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
1.1k
Fork
228
Merge medio
4g 3h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tus/tus-node-server

Tutte le issue di tus/tus-node-server

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.