-
Notifications
You must be signed in to change notification settings - Fork 71
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
uncaughtException: Cannot read properties of undefin ed (reading '_id') #560
Comments
I started getting this error last week after updating a couple of MongoDB-related dependencies in a project. mongodb is at Putting this in
|
Also getting this error, changing the mongodb version didn't fix it for me. I have tracked down the error (at least mine) to |
It helped me, it's working correctly |
Hi, this error still is problem for someone. May you help me ? [1] TypeError: Cannot read properties of undefined (reading '_id') |
I just installed mongodb module in my project and problem solved immediately. |
If you are using yarn, adding this to the package.json will fix it.
|
This Worked for me. TY |
I just had this same issue, however Im not using Yarn.
This instantly fixed the issue |
This worked for me, before trying this i didn't had the mongodb module in my project, latest version also works. Thank you, can finally upload images |
Resolved by #561 |
I made a fork if you would like to use the latest versions of mongoose/mongodb, add "multer-gridfs-storage": "meme8383/multer-gridfs-storage#f82252c" to your package.json (add commit or maintain your own fork for security). Tested on mongodb 6.3.0 and mongoose 8.0.1. |
Fixed another issue relating to file count limits and mongodb update in commit 32d2198. Feel free to use my fork or make your own as it appears this package is no longer maintained. |
If you dont have mongodb installed in your project and multer and multer-gridfs-storage installed; you will get error while installing mongodb by multer and multer-gridfs-storage. Step 2 : Step 3: Step 4: |
Can you share you Package.json file |
i have this same error, my dependencies are "mongoose": "^8.0.4", TypeError: Cannot read properties of undefined (reading '_id') |
I have the same issue and want to try the fix in meme8383's fork. I am a newbie and am reading up on how to do so. How does a bug fix get incorporated in the latest version that is downloadable using npm? |
The author has to merge a fix and publish it. I was going to rewrite this library, but I switched to using an actual cloud provider for cloud storage instead. You can use my fork by setting the version to |
Thanks Meme8383, I cloned your fork and used it in my app and it works, .... problem solved. |
can it work on production level? |
That is for you to decide. This library has not been tested thoroughly with the most recent versions of these libraries. If it is necessary, I would recommend maintaining your own fork in case other issues need fixing. Using my fork with the commit reference should work fine as long as you thoroughly test your application. However, I don't think you should be using MongoDB for file storage in production anyways. |
is this repository dead? why no update over 3 years? |
Can't say yes or no but this issue isn't resolved yet. I'm still getting this error with latest version of Mongodb. |
You can use my branch by adding meme8383/multer-gridfs-storage to your package.json, I fixed that and another issue. However, not a great fix, since optimally this should be rewritten and thoroughly tested for the newest versions. |
I admire @meme8383 's output, but this, https://github.com/lykmapipo/mongoose-gridfs, and https://github.com/aheckmann/gridfs-stream all should be properly updated to the latest mongodb driver for proper long-term projects |
Its working. Thanks @meme8383. Can you please brief how you fixed it and came to know what function or file need to be fixed? |
master...meme8383:multer-gridfs-storage:master |
Hi , Its throwing the above error in latest version or downgraded versions as well ."mongoose": "^8.2.4", |
Working on date: 02/05/2024. |
By downgrading the mongoDB version issue is fixed
This worked for me also |
just downgrade the multer version
because there is dependency conflict between multer and multer-gridfs-storage. Specifically, [email protected] requires multer@^1.4.2. |
Thank you so much, it's working |
I use yarn Uncaught Exception: Cannot read properties of undefined (reading '_id') |
downgrade multer version
|
I found the error was occurring because the _id was coming back as undefined. I made a PR to use the id coming back from Mongo DB in the fromMulterStream function: #586 Had some trouble compiling the code (ts errors) so edited the system generated file directly so you'd see what I meanthe ts errors were coming from the following modules and file:
Thanks, hope it helps ! |
See github issue with info on the bug: devconcept#560 Changes pulled from devconcept/multer-gridfs-storage@master...meme8383:multer-gridfs-storage:master
See github issue with info on the bug devconcept#560 Changes pulled from devconcept/multer-gridfs-storage@master...meme8383:multer-gridfs-storage:master
The text was updated successfully, but these errors were encountered: