adrianhajdin / threads

Develop Threads, Next.js 13 app that skyrocketed to 100 million sign-ups in less than 5 days, and dethroned giants like Twitter, ChatGPT, and TikTok to become the fastest-growing app ever!
https://threads-psi.vercel.app
1.49k stars 285 forks source link

Error: Failed to create/update user: Plan executor error during findAndModify :: caused by :: E11000 duplicate key error collection: test.users index: userName_1 dup key: { userName: null } #99

Closed Mishael-Joe closed 8 months ago

Mishael-Joe commented 10 months ago

threadserror

MHamza-Aslam commented 10 months ago

can i resolve this issue

ERy03 commented 8 months ago

I tried changing updateUser method from user actions and trying to find any mistakes in AccountProfile, but what solved my problem was deleting the collections from mongodb. (You can also delete the users from clerk in order to reuse your email) In my case I had my mongoose user schema variable set as userName instead of all lowercase username. I decided to change it half way to username but because the db already had a user collection with userName, it was not allowing me to create / update. Hopefully this will help any of those who encounter this error.

Screenshot 2024-01-12 at 21 17 50
Mishael-Joe commented 8 months ago

Thanks 👍