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

The global definition of Mongo.Collection has changed since the file-collection package was loaded. #128

Open
g41n opened this issue Jun 21, 2016 · 3 comments
Labels

Comments

@g41n
Copy link

g41n commented Jun 21, 2016

Hi to all,
this is the error I have replacing CFS with FC in an existing application:

gridFS_client.coffee:16
Uncaught Error: [The global definition of Mongo.Collection has changed since the file-collection package was loaded. Please ensure that any packages that redefine Mongo.Collection are loaded before file-collection.]

I don't know how meteor imports packages, if the order is in .meteor/packages FC is the last one.

I've also found that build packages are in .meteor/local/build/programs/web.browser/packages/ and, in alphabetical order, only webapp is after FC:

[...]
underscore.js
underscore.js.map
vsivsi_file-collection.js
vsivsi_file-collection.js.map
webapp.js
webapp.js.map

Other things I can check to verify the inclusion order?

Meteor version is 1.3.3.1

Any hint would be appreciated.
Thanks in advance :)

@vsivsi
Copy link
Owner

vsivsi commented Jun 22, 2016

Hi, yes, Meteor no longer provides any guarantees regarding package load order for packages that don't explicitly depend on one another. file-collection doesn't depend on any package that replaces the default Mongo.Collection object provided by Meteor. And it really can't because there are many such packages, with new ones probably being created all the time (or rather, new packages that depend on such packages). The only way file-collection could be made completely safe would be for it to depend on all other packages which is clearly untenable.

The solution? Don't use packages that Monkey patch or replace the objects that define the Meteor API. The check you've run into was added to this package to protect everyone's sanity. If Mongo.Collection is being modified by other packages in unpredictable ways, then I can't provide or reasonably support any standard of compatibility or data integrity for file-collection.

There's a long history for this issue, and it all stems from other packages (that provide useful functionality) being implemented using a terrible anti-pattern. It sucks, but it's not a problem I can fix. Here's a trail of tears for you to follow if you want to fully appreciate how messed up this is for Meteor:

meteor/meteor#6416
https://github.com/vsivsi/meteor-defender
vsivsi/meteor-file-sample-app#2 (comment)
#61
#125
vsivsi/meteor-job-collection#97

@dpatte
Copy link

dpatte commented Aug 11, 2017

I had this issue, but moving vsivsi:file-collection to the end of the package list resolved it, at least for me.

@egemon
Copy link

egemon commented Dec 21, 2017

Thank u @dpatte !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants