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

Bug in Minimongo query which prevents correct autorun/observe #4377

Closed
mitar opened this issue May 13, 2015 · 1 comment
Closed

Bug in Minimongo query which prevents correct autorun/observe #4377

mitar opened this issue May 13, 2015 · 1 comment

Comments

@mitar
Copy link
Collaborator

@mitar mitar commented May 13, 2015

If one is calling collection.update(id, {a: array}); where array is kept and modified in place between calls to collection.update(id, {a: array});, Minimongo does not detect that anything changed because it keeps the array as a reference. So when a user modifies array to issue a new query, it also modifies internal Minomongo storage, so update does not do anything, thus not triggering autorun or observe on data change.

This is pretty tricky to debug. Because if you read data from Minimongo collection, latest data is there. Only observe and autoruns are not triggered.

But if you look closely you will see that latest data is there already before you call update. Very peculiar indeed.

See the reproduction. If you run it in the server console you should see something like:

added { '0': { a: [], _id: 'PE4PpPNNKpcKaYwDm' } }
changed { '0': { a: [ '0' ], _id: 'PE4PpPNNKpcKaYwDm' },
  '1': { a: [], _id: 'PE4PpPNNKpcKaYwDm' } }

Instead of:

added { '0': { a: [], _id: 'ugr4u6TqaifWvGueD' } }
changed { '0': { a: [ '0' ], _id: 'ugr4u6TqaifWvGueD' },
  '1': { a: [], _id: 'ugr4u6TqaifWvGueD' } }
changed { '0': { a: [ '0', '1' ], _id: 'ugr4u6TqaifWvGueD' },
  '1': { a: [ '0' ], _id: 'ugr4u6TqaifWvGueD' } }
changed { '0': { a: [ '0', '1', '2' ], _id: 'ugr4u6TqaifWvGueD' },
  '1': { a: [ '0', '1' ], _id: 'ugr4u6TqaifWvGueD' } }
changed { '0': { a: [ '0', '1', '2', '3' ], _id: 'ugr4u6TqaifWvGueD' },
  '1': { a: [ '0', '1', '2' ], _id: 'ugr4u6TqaifWvGueD' } }
changed { '0': { a: [ '0', '1', '2', '3', '4' ], _id: 'ugr4u6TqaifWvGueD' },
  '1': { a: [ '0', '1', '2', '3' ], _id: 'ugr4u6TqaifWvGueD' } }
@glasser
Copy link
Member

@glasser glasser commented May 19, 2015

Thanks, fixed! Looks like this was mostly specific to replacement updates (not most $op updates).

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.