hcengineering/platform · warning
Failed to reject multipart upload
Error message
Failed to reject multipart upload
What it means
multipartUploadAbort POSTs to `<baseUrl>/abort?uploadId=...` to discard a failed multipart session; it runs in uploadMultipart's catch block whenever the upload fails or is aborted. If the abort call itself returns non-ok, it throws 'Failed to reject multipart upload'. This is a cleanup-path failure — the original upload error is what actually matters.
Source
Thrown at foundations/core/packages/storage-client/src/upload.ts:256
try {
const response = JSON.parse(result.responseText)
return { etag: response.etag }
} catch (err) {
throw new Error(`Failed to parse response for part ${partNumber}`)
}
}
async function multipartUploadAbort (baseUrl: string, headers: Record<string, string>, uploadId: string): Promise<void> {
const url = new URL(concatLink(baseUrl, '/abort'))
url.searchParams.set('uploadId', uploadId)
const response = await fetch(url, {
method: 'POST',
headers
})
if (!response.ok) {
throw new Error('Failed to reject multipart upload')
}
}
View on GitHub (pinned to 63e28dc964)
Solutions
- Wrap or patch multipartUploadAbort to log-and-swallow on cleanup: a failed abort should not mask the original upload error.
- Re-authenticate before cleanup if the token expired during the upload.
- Rely on server-side multipart lifecycle expiry to garbage-collect orphaned sessions if abort keeps failing.
- Verify the uploadId used came from a successful multipartUploadCreate response.
Example fix
// before: cleanup failure masks the real cause
} catch (err) {
if (uploadId !== undefined) await multipartUploadAbort(url, headers, uploadId) // may throw 'Failed to reject...'
throw err
}
// after: best-effort cleanup
} catch (err) {
try { if (uploadId !== undefined) await multipartUploadAbort(url, headers, uploadId) }
catch (abortErr) { console.warn('multipart abort failed', abortErr) }
throw err
} Defensive patterns
Strategy: try-catch
Validate before calling
// only attempt abort if a session was actually created if (uploadId === undefined) return // nothing to abort
Type guard
null
Try / catch
try {
await multipartUploadAbort(baseUrl, headers, uploadId)
} catch (err) {
// cleanup-path failure: log only, never mask the original upload error
console.warn('Failed to reject multipart upload', uploadId, err)
} Prevention
- Always treat abort failures as non-fatal — log and continue.
- Re-authenticate before cleanup if the upload failed with an auth error.
- Depend on server-side session expiry to reclaim orphaned multipart uploads.
- Only call abort with an uploadId returned from a successful create.
When it happens
Trigger: uploadMultipart failed (or was aborted) and the compensating POST /abort returns non-ok: 404 (uploadId already aborted or never created), 401/403 (token expired — note the original failure may already have consumed it), 5xx from storage, or fetch-level network error rethrown by the caller.
Common situations: Token expired during a long upload, so both the part/complete call and the abort call fail; aborting an upload whose server-side session already timed out; transient network blip hitting exactly the cleanup request; uploadId undefined-guard passing but the session never existed.
Related errors
- Failed to initialize multipart upload
- Failed to complete multipart upload
- missing files
- Failed to parse response for part ${partNumber}
- invalid upload id
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/15a5c7f58b0c0330.
Report an issue: GitHub.