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

[bug]: Cannot read properties of undefined (reading 'ordinal') #900

Closed
2 tasks
prpanto opened this issue Aug 1, 2024 · 5 comments
Closed
2 tasks

[bug]: Cannot read properties of undefined (reading 'ordinal') #900

prpanto opened this issue Aug 1, 2024 · 5 comments
Labels
area:packages issue regarding one of the uploadthing packages bug: medium priority Something isn't working status: in progress work is currently underway to address this issue workaround available solution exists for the issue using existing functionality, although it may not be optimized for DX

Comments

@prpanto
Copy link

prpanto commented Aug 1, 2024

Provide environment information

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
    Memory: 13.25 GB / 31.36 GB
  Binaries:
    Node: 20.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

Describe the bug

I use a fresh Nuxt project with version 3.12.4
@uploadthing/nuxt: 6.5.9
uploadthing: 6.13.2

just copy paste the code from playground example of Nuxt and then on upload file this error show.

Link to reproduction

https://stackblitz.com

To reproduce

<UploadButton
  :config="{
    endpoint: 'imageUpload',
    onClientUploadComplete(response) {
      console.log(`onClientUploadComplete`, response);
      alert('Upload Completed');

      response[0]?.serverData;
    },
    onUploadBegin: () => {
      console.log(`onUploadBegin`);
    },
  }"
/>
import type { FileRouter } from "uploadthing/h3"
import { createUploadthing } from "uploadthing/h3"

const f = createUploadthing()

export const uploadRouter = {
  imageUpload: f({
    image: {
      maxFileSize: "4MB",
      maxFileCount: 4,
    },
  })
    .middleware(({ event }) => {
      event;

      return {}
    })
    .onUploadComplete(({ file, metadata }) => {
      file;
      metadata;

      return {}
    }),
} satisfies FileRouter

export type UploadRouter = typeof uploadRouter

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Code of Conduct

  • I agree to follow this project's Code of Conduct
@prpanto prpanto added area:packages issue regarding one of the uploadthing packages 🐛 bug: unconfirmed labels Aug 1, 2024
@markflorkowski markflorkowski added bug: medium priority Something isn't working status: in progress work is currently underway to address this issue workaround available solution exists for the issue using existing functionality, although it may not be optimized for DX and removed 🐛 bug: unconfirmed labels Aug 5, 2024
@markflorkowski
Copy link
Collaborator

I ran into this as well. IIRC, you need to set a logLevel in your Nuxt config:

export default defineNuxtConfig({
  devtools: { enabled: true },
  modules: ["@uploadthing/nuxt"],
  compatibilityDate: "2024-07-26",
+  uploadthing: {
+    logLevel: "info",
+  },
});

#886 Should include a fix so that this is not required, but for now manual config should do it.

@prpanto
Copy link
Author

prpanto commented Aug 6, 2024

I add it and I have these messages:

@markflorkowski
Copy link
Collaborator

Hmm I am able to reproduce that locally as well. If you set config: { mode: 'manual' } in your component:

<UploadButton
  :config="{
    endpoint: 'imageUpload',
    onClientUploadComplete(response) {
      console.log(`onClientUploadComplete`, response);
      alert('Upload Completed');

      response[0]?.serverData;
    },
    onUploadBegin: () => {
      console.log(`onUploadBegin`);
    },
    config: { mode: 'manual' },
  }"
/>

Does it still fail with a 500?

@prpanto
Copy link
Author

prpanto commented Aug 6, 2024

Hmm I am able to reproduce that locally as well. If you set config: { mode: 'manual' } in your component:

<UploadButton
  :config="{
    endpoint: 'imageUpload',
    onClientUploadComplete(response) {
      console.log(`onClientUploadComplete`, response);
      alert('Upload Completed');

      response[0]?.serverData;
    },
    onUploadBegin: () => {
      console.log(`onUploadBegin`);
    },
    config: { mode: 'manual' },
  }"
/>

Does it still fail with a 500?

Now works...

How to make it to upload automatically without the option manual because right now it wants two clicks?

@markflorkowski
Copy link
Collaborator

Ok, that was what I was worried about. This is definitely a bug.

You can try using this canary version: @uploadthing/nuxt@6.5.10-canary.01a466a

Note: I believe you will need to add an override for @uploadthing/vue@6.6.4-canary.01a466a as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:packages issue regarding one of the uploadthing packages bug: medium priority Something isn't working status: in progress work is currently underway to address this issue workaround available solution exists for the issue using existing functionality, although it may not be optimized for DX
Projects
None yet
Development

No branches or pull requests

3 participants