Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golden Retriever - Unable to re-select the same file after refreshing - "onBeforeFileAdded" error #4769

Closed
2 tasks done
oqadiSAK opened this issue Oct 29, 2023 · 2 comments · Fixed by #4799
Closed
2 tasks done
Assignees
Labels

Comments

@oqadiSAK
Copy link

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

https://uppy.io/examples/dashboard/

Steps to reproduce

  • Open the Uppy dashboard example with the Golden Retriever plugin enabled: https://uppy.io/examples/dashboard/
  • Upload a file.
  • Refresh the page while the file is uploading.
  • After the refresh (enable Golden Retriever again), the session is restored, so you will notice a "ghost" file remains in the upload queue.
  • Click on re-select button.
  • Attempt to re-select the same file for upload.

Expected behavior

The user should be able to re-select the same file after a page refresh without encountering errors.

Actual behavior

  • Upon trying to re-select the same file, the Uppy dashboard throws the following error:
Error: Cannot add the file because onBeforeFileAdded returned false.
    at Uppy._checkAndUpdateFileState2 (https://rqq2rw.csb.app/node_modules/@uppy/core/lib/Uppy.js:1077:15)
    at Uppy.addFiles (https://rqq2rw.csb.app/node_modules/@uppy/core/lib/Uppy.js:462:181)
    at Dashboard.addFiles (https://rqq2rw.csb.app/node_modules/@uppy/dashboard/lib/Dashboard.js:283:19)
    at Dashboard.handleInputChange (https://rqq2rw.csb.app/node_modules/@uppy/dashboard/lib/Dashboard.js:385:14)
    at AddFiles.onFileInputChange (https://rqq2rw.csb.app/node_modules/@uppy/dashboard/lib/components/AddFiles.js:24:18)
    at HTMLInputElement.T (https://rqq2rw.csb.app/node_modules/preact/dist/preact.module.js:217:10)

NOTE: When you cancel the restored session and try to re-select the file, the uploading consumes from where it left off.

@arturi
Copy link
Contributor

arturi commented Nov 2, 2023

@Murderlon do you think it could have something to do with the way you refactored onBeforeFileAdded?

@ShanArosh
Copy link

ShanArosh commented Nov 14, 2023

I'm also experiencing this. but haven't used onBeforeFileAdded function.


  const BunnyVideo = new Uppy({ id: "bunny-video" })
    .use(Tus, {
      endpoint: import.meta.env.REACT_APP_BUNNY_TUS_ENDPOINT,
      // @ts-ignore
      headers: async (file) => {
        const headers = await api.bunny.bunnyControllerSignUploadUrl({
          classId: cid,
          fileName: file.name,
          fileType: file.type,
          publishAt: new Date().toISOString(),
        });
        return  headers;
      },
    })
    .use(Webcam)
    .use(GoldenRetriever);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants