Skip to content

useUpload() does not forward the controller's retryUpload, so hosts cannot retry a single failed file #392

Description

@BSalaeddin

Found while adding per-file retry to a failed upload tile in a host app (@upupjs/react 3.2.0, re-exported verbatim by @upupjs/next).

What exists internally

  • The controller implements retryUpload(fileId) (dist/index.js ~L3741) and puts it on the context as providerValues.upload.retryUpload (~L3897).
  • useUploaderUploadControls() exposes upload.retryUpload; the vendor's own upup-retry-btn calls it (~L2506).

What a host can reach

  • UploaderRef (index.d.ts L8) is { useUpload() }{ error, files, loading, progress, upload, resetState, uploadFiles, setFiles, replaceFiles }. No retryUpload, no core, no on.
  • useUpload() (~L3944) receives the controller's retryUpload but forwards only startUpload.
  • useUploaderUploadControls() resolves only inside UploaderContextProvider, and <UpupUploader> renders fixed children (no children prop), so a host cannot mount anything inside the provider.
  • onError is (message: string) => void: no per-file error callback. FileUploadResult{status:'failed', error} and the 'upload-error': {error, file?} core event are only readable through the headless core/on, i.e. by abandoning the visual uploader.

Ask
Forward retryUpload from useUpload() (one line) so UploaderRef.useUpload().retryUpload(fileId) works, and/or add a per-file failure callback (onFileUploadError?: (file: File, error: string) => void) next to onFileUploadStart/onFileUploadComplete.

Workaround shipped on the host side meanwhile: keep the raw File from onFileUploadStart and re-enter it through initialFilesuploadFiles, re-keying the tile by File identity because a fresh core assigns a new id.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions