Open sanjarbek-ismatov opened 1 year ago
I started getting this error last week after updating a couple of MongoDB-related dependencies in a project. mongodb is at 4.17.1
in the project but Yarn was installing some 6.x.x
versions for other dependencies.
Putting this in package.json
has resolved it for me:
"resolutions": {
"mongodb": "4.17.1"
},
Also getting this error, changing the mongodb version didn't fix it for me. I have tracked down the error (at least mine) to fromMulterStream
method. The value passed to emitFile
when the finish event is triggered is undefined.
Also getting this error, changing the mongodb version didn't fix it for me. I have tracked down the error (at least mine) to
fromMulterStream
method. The value passed toemitFile
when the finish event is triggered is undefined.
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') [1] at GridFSBucketWriteStream.emitFile (/home/cppdozer/Projects/encore/server/node_modules/multer-gridfs-storage/src/gridfs.ts:353:12) [1] at GridFSBucketWriteStream.emit (node:events:529:35) [1] at GridFSBucketWriteStream.emit (node:domain:489:12) [1] at finish (node:internal/streams/writable:748:10) [1] at processTicksAndRejections (node:internal/process/task_queues:82:21) [1] [nodemon] app crashed - waiting for file changes before starting...
Hi, this error still is problem for someone. May you help me ?
[1] TypeError: Cannot read properties of undefined (reading '_id') [1] at GridFSBucketWriteStream.emitFile (/home/cppdozer/Projects/encore/server/node_modules/multer-gridfs-storage/src/gridfs.ts:353:12) [1] at GridFSBucketWriteStream.emit (node:events:529:35) [1] at GridFSBucketWriteStream.emit (node:domain:489:12) [1] at finish (node:internal/streams/writable:748:10) [1] at processTicksAndRejections (node:internal/process/task_queues:82:21) [1] [nodemon] app crashed - waiting for file changes before starting...
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.
"resolutions": {
"multer-gridfs-storage/mongodb": "^5.9.1"
},
If you are using yarn, adding this to the package.json will fix it.
"resolutions": { "multer-gridfs-storage/mongodb": "^5.9.1" },
This Worked for me. TY
I just had this same issue, however Im not using Yarn. To resolve I needed to install mongodb v5.9.1
npm install mongodb@5.9.1
This instantly fixed the issue
I just had this same issue, however Im not using Yarn. To resolve I needed to install mongodb v5.9.1
npm install mongodb@5.9.1
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 1 : npm uninstall multer multer-gridfs-storage
Step 2 : npm i mongodb@5.9.1 (In my case only this version worked. Check with the latest version first otherwise this is your only option)
Step 3: npm i multer-gridfs-storage
Step 4: npm i multer
I just had this same issue, however Im not using Yarn. To resolve I needed to install mongodb v5.9.1
npm install mongodb@5.9.1
This instantly fixed the issueThis 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
Can you share you Package.json file
i have this same error, my dependencies are "mongoose": "^8.0.4", "multer": "^1.4.4", "multer-gridfs-storage": "^5.0.2", D:\All\MearStackProject\music-app\backend\node_modules\multer-gridfs-storage\lib\gridfs.js:306 id: f._id, ^
TypeError: Cannot read properties of undefined (reading '_id') at GridFSBucketWriteStream.emitFile (D:\All\MearStackProject\music-app\backend\node_modules\multer-gridfs-storage\lib\gridfs.js:306:31)
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?
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 meme8383/multer-gridfs-storage#32d2198
in your package.json
.
Thanks Meme8383, I cloned your fork and used it in my app and it works, .... problem solved.
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
meme8383/multer-gridfs-storage#32d2198
in yourpackage.json
.
can it work on production level?
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
meme8383/multer-gridfs-storage#32d2198
in yourpackage.json
.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?
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. Mongodb@5.9.1 works fine .
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. Mongodb@5.9.1 works fine .
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
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. Mongodb@5.9.1 works fine .
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.
Its working. Thanks @meme8383. Can you please brief how you fixed it and came to know what function or file need to be fixed?
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. Mongodb@5.9.1 works fine .
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.
Its working. Thanks @meme8383. Can you please brief how you fixed it and came to know what function or file need to be fixed?
https://github.com/devconcept/multer-gridfs-storage/compare/master...meme8383:multer-gridfs-storage:master Pretty simple fixes, but there are bound to be more issues. I was going to rewrite the library for the updated packages but we decided to switch away from using Mongo for file storage. Test your project thoroughly if you use this.
Hi , Its throwing the above error in latest version or downgraded versions as well ."mongoose": "^8.2.4", "multer": "^1.4.5-lts.1", "multer-gridfs-storage": "^5.0.2", Does anyone resolved the issue with compatible versions? Can you tell me the versions used ?
I just had this same issue, however Im not using Yarn. To resolve I needed to install mongodb v5.9.1
npm install mongodb@5.9.1
This instantly fixed the issue
Working on date: 02/05/2024. This issue still persists. only way is to downgrade to mongodb, 5.9.1
By downgrading the mongoDB version issue is fixed
npm i mongodb@5.9.1
This worked for me also
Hi , Its throwing the above error in latest version or downgraded versions as well ."mongoose": "^8.2.4", "multer": "^1.4.5-lts.1", "multer-gridfs-storage": "^5.0.2", Does anyone resolved the issue with compatible versions? Can you tell me the versions used ?
just downgrade the multer version
npm install multer@1.4.2 --save
because there is dependency conflict between multer and multer-gridfs-storage. Specifically, multer-gridfs-storage@5.0.2 requires multer@^1.4.2.
Thank you so much, it's working
I use yarn I downgraded the version of mongodb and added resolutions but none of it works "mongodb": "5.9.1", "mongoose": "^5.13.14", "resolutions": { "multer-gridfs-storage/mongodb": "^5.9.1" }
Uncaught Exception: Cannot read properties of undefined (reading '_id') TypeError: Cannot read properties of undefined (reading '_id') at GridFSBucketWriteStream.emitFile
downgrade multer version
npm install multer@1.4.2 --save
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: https://github.com/devconcept/multer-gridfs-storage/pull/586
the ts errors were coming from the following modules and file:
Found 7 errors in 5 files.
Errors Files
1 node_modules/@types/eslint/helpers.d.ts:1
1 node_modules/@types/markdown-it/lib/index.d.ts:151
1 node_modules/@types/mongodb/index.d.ts:58
3 src/gridfs.ts:216
1 ../../../../node_modules/@types/eslint/helpers.d.ts:1
Thanks, hope it helps !