better error in case of upload problems

Massimo Melina committed Jan 1, 2026 at 23:52 UTC fbe00de097fa7157237235eed404b2de7d961109
1 file changed +3 -8
src/upload.ts
+3 -8
@@ -112,13 +112,8 @@ export function uploadWriter(base: VfsNode, baseUri: string, path: string, ctx:
112 // try to catch errors early (sync): this is avoiding on chrome139 when uploading a big file (1GB) to get miss the error code and have to make a `simulate`
113 try { fs.accessSync(tempName, fs.constants.W_OK) }
114 catch {
115 - try {
116 - fs.closeSync(fs.openSync(tempName, 'w'))
117 - fs.unlinkSync(tempName)
118 - }
119 - catch(e: any) {
120 - return fail(HTTP_SERVER_ERROR, e.code)
121 - }
115 + fs.closeSync(fs.openSync(tempName, 'w'))
116 + fs.unlinkSync(tempName)
117 }
118 const stats = try_(() => fs.statSync(tempName))
119 const resumableSize = stats?.size || 0
@@ -247,7 +242,7 @@ export function uploadWriter(base: VfsNode, baseUri: string, path: string, ctx:
242 }
243 catch (e: any) {
244 releaseFile()
250 - throw e
245 + return fail(HTTP_SERVER_ERROR, e.code || e.message || String(e))
246 }
247
248 async function overwriteAnyway() {