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
FileCollection.remove() on the Client side triggers Meteor find() selector bug when combined with packages that transform Collection documents in certain ways #152
Comments
Hi, this sounds very concerning. I have not received any reports of such behavior in the more than two years this package has been available. Notably, the sample app uses exactly this method (client side remove) and it does not do what you describe here. See code: https://github.com/vsivsi/meteor-file-sample-app/blob/master/sample.coffee#L102 If you have indeed found a way to easily and accidentally delete all files remotely, that is very serious. Please provide a link to a working minimal reproduction code base and I will look into it quickly once i receive it. |
Thanks for the lightning-fast response! I'll try to make a minimalistic reproduction of the problem right now (maybe I can even find out in the process if that was an actual problem or some logical/structural mistake that I made). I'll keep in touch |
Ok @vsivsi , sorry for taking so long! The error reproduction is in here: https://github.com/RaniereSouza/meteor-fc-cli-rmv-problem (I even added you as collaborator, just in case) I really hope it's just me making some silly mistake, but I still can't understand what am I doing wrong |
Updated to fix typos in the reproduction @RaniereSouza Hi, Okay, I've dug into this a bit and have been able to reproduce what you are describing using the project you provided. Thanks for setting that up for me. TL;DR Either stop using Gory details: I've traced the problem to this line in the source code for FileCollection: In the sample app (and every other project I've encountered) that line of code works as expected, but in your project it does not. For a client-side remove (which must have an But this only happens in your app, so something must be special. And it is. Your app is not really "minimal" as far as Collections are concerned, because you are using the Just to understand this rather catastrophic bug, I spent another couple of hours trying to narrow down the root cause and it appears that there is some bug in Here is the evidence: Load up your reproduction app and create three new "events" with images using the client UI. Now, in two other console windows run In the "mongo" window try this: > db.images.files.find().count()
3
> db.images.files.find(db.images.files.findOne()).count()
1 Now in the "shell" window try this: > Images.find().count()
3
> Images.find(Images.findOne()).count()
3 Uh oh! Not good! Let's see if we can repro that on another FileCollection: // Still in the "shell" console
> testFC = new FileCollection("testFC")
[... object stuff ...]
// Create some empty files
> testFC.insert()
[... object ID ...]
> testFC.insert()
[... object ID ...]
> testFC.insert()
[... object ID ...]
// Now test the behavior of find()
> testFC.find().count()
3
> testFC.find(Images.findOne()).count()
1
// Hmm, works on this FileCollection!
// But wait, what if we define a helper?
> testFC.helpers({ url: () => "http://woot.com"})
// Now what will happen?
> testFC.find().count()
3
> testFC.find(testFC.findOne()).count()
3
// BINGO, something in dburles:collection-helpers is breaking .find() I haven't dug into what is going on in that other package, but I will say that all of the nastiest bugs I've encountered in Meteor development have resulted from strange interactions with Atmosphere packages that monkey patch or replace the functionality of Meteor systems packages. And this appears to be another example. Just to confirm that this doesn't actually require a FileCollection to break (a normal Mongo Collection with the wrong type of document will suffice): // Keep going in your "shell" console
> testOC = new Mongo.Collection("testOC")
[... object stuff ...]
// Insert the gridFS file documents from testFC
> testFC.find().forEach((d) => testOC.insert(d))
// Now test the behavior of find()
> testOC.find().count()
3
> testOC.find(testOC.findOne()).count()
1
// So far so good, now add a helper to this vanilla Mongo Collection
> testOC.helpers({ url: () => "http://woot.com"})
> testOC.find().count()
3
> testOC.find(testOC.findOne()).count()
3
// And FAIL! FileCollection is not required.
// dburles:collection-helpers is breaking .find() even for vanilla Mongo Collections! |
@RaniereSouza Note that there were a bunch of copy-paste typos in the code blocks above, but everything should be good now... |
Oh, I see... WOW, this is really unexpected. I'll look if there's some Issue in the Either way, many thanks for the careful look at my particular case! I'll close this topic, as it is a problem that isn't related to |
Just for completeness, a minimal reproduction of this bug in |
It has been confirmed that this is occurring due to a bug in Meteor core. The next version of file-collection will check for and guard against this situation. Meteor issue: meteor/meteor#8329 |
…gered by [this Meteor bug](#152). * Updated resumable.js to latest upstream version * Removed jquery Atmosphere package as a dependency, as resumable.js no longer requires it. * Documentation improvements
Hello, @vsivsi !
Thanks for your hard work, that's a really great package and I'm starting to use it (and I intend to apply it in Production environment).
I'm having a little problem, maybe someone also had the same problem, maybe you've already answered someone about it (couldn't find it in the Issues stack though)... I'm doing
.remove()
operations on the Client side (by file's_id
). The thing is - even with the correct_id
(ObjectID
), the operation returns the number 0, and despite that, it removes ALL the files from theFileCollection
in the database (verified on mongo shell). The Allow/Deny rules are all open (all Allow rules return true, no Deny rules), just for the sake of testing it in Development environment. I'm using Meteor 1.4.1.3 (MongoDB 3.2), and the version 1.3.6 of this package. There's nothing special on this.remove()
operation, it's just a simple and plain.remove()
operation on the Client side, and yet this error occurs. I'm not understanding it, maybe you could help me understand this problem.Thanks in advance
The text was updated successfully, but these errors were encountered: