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

Latest version overwrites MongoDB types affecting other packages, i.e. connect-mongo #502

Open
onebrother21 opened this issue Aug 10, 2022 · 4 comments
Labels
bug A feature or code that is not working properly

Comments

@onebrother21
Copy link

onebrother21 commented Aug 10, 2022

Describe the bug
Version 5.0.2 overwrites mongoDB/mongoose types that break other mongoDB/mongoose-dependent packages, like connect-mongo. Not sure which set of types are actually doing the harm.

Environment

  • I'm using multer-gridfs-storage version 5.0.2.
  • My installed MongoDb version is 4.81. <-- I do not need this in this package, and simply installed it to see if it would address the issue. It did not.
  • I have Multer 1.4.4-lts.1 installed to upload files. <-- also tried 1.4.5-lts.1, no luck.
  • The Node version used to run the code is 16.14.0.

To Reproduce
npm i connect-mongo -> package.json shows "connect-mongo": "^4.6.0";
npm i [email protected] -> package.json shows "multer": "^1.4.4-lts.1";
npm i multer-gridfs-storage -> npm shows warnings/errors addressed in #490 , package.json shows "multer-gridfs-storage": "^5.0.2".

Upon build, the following errors are generated:

tsc

node_modules/connect-mongo/build/main/lib/MongoStore.d.ts:2:55 - error TS2305: Module '"mongodb"' has no exported member 'WriteConcernSettings'.

2 import { Collection, MongoClient, MongoClientOptions, WriteConcernSettings } from 'mongodb';
~~~~~~~~~~~~~~~~~~~~

node_modules/mongoose/types/aggregate.d.ts:22:25 - error TS2694: Namespace '"C:/Users/servi/Desktop/d-drive/cctx/oba-express/node_modules/@types/mongodb/index"' has no exported member 'CollationOptions'.

22 collation?: mongodb.CollationOptions;
~~~~~~~~~~~~~~~~

node_modules/mongoose/types/aggregate.d.ts:36:23 - error TS2694: Namespace '"C:/Users/servi/Desktop/d-drive/cctx/oba-express/node_modules/@types/mongodb/index"' has no exported member 'ExplainVerbosityLike'.

36 explain?: mongodb.ExplainVerbosityLike;

And 60 more...The build command output ends with this summary:

Found 63 errors in 11 files.

Errors Files
1 node_modules/connect-mongo/build/main/lib/MongoStore.d.ts:2
9 node_modules/mongoose/types/aggregate.d.ts:22
3 node_modules/mongoose/types/collection.d.ts:8
4 node_modules/mongoose/types/connection.d.ts:75
1 node_modules/mongoose/types/error.d.ts:37
1 node_modules/mongoose/types/index.d.ts:467
7 node_modules/mongoose/types/indexes.d.ts:18
26 node_modules/mongoose/types/models.d.ts:23
8 node_modules/mongoose/types/query.d.ts:103
2 node_modules/mongoose/types/schemaoptions.d.ts:43
1 node_modules/mongoose/types/session.d.ts:4

Expected behavior
Upon build, no errors generated. When this package is removed only, build runs perfectly as expected.

@onebrother21 onebrother21 added the bug A feature or code that is not working properly label Aug 10, 2022
@devconcept
Copy link
Owner

I guess hardcoding the version of the types "@types/mongodb": "^3.5.25" is a problem. Will fix it soon

@onebrother21
Copy link
Author

Just checking in on progress. Any ETA?

@judaschwartz
Copy link

It looks like this was fixed and merged to master 8 months ago
41685ef
Is there a reason why a new release has not been created for this?

@devconcept
Copy link
Owner

Hi. Multer decided to nuke storages for the new version. If that is the case there is not a lot of purpose for this module. I think is a bad idea but nothing stops multer for making a bad decision. In fact they are still stuck in the .lts-1 version and not releasing a minor version or the major so is not clear what is going to happen. This is why I stopped developing to see what would happen. I can release a new major version with all the fixes but due to incompatibilities with mongodb versions I have to rewrite a lot and also multer can publish a new major version and force me to rewrite again. I hope you can understand my position. I've been thinking on releasing as it is lately. Please understand that this is a plugin and it depends of what is decided on the parent module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A feature or code that is not working properly
Projects
None yet
Development

No branches or pull requests

3 participants