Note that there are some explanatory texts on larger screens.

plurals
  1. POMeteor and Iron-Router Subscription Exception from Deps recompute: Error: Member already exists
    primarykey
    data
    text
    <p><strong>Important: I'm currently working with Meteor and Iron-Router both in the <em>SHARK</em> branch</strong></p> <p>To abstract the problem, lets say I have two routes: </p> <pre><code>// Home this.route('home', { path: '/', layoutTemplate: 'layout', action: function() { // Performing some animation } }); // User profile this.route('profile', { path: '/profile/:id', controller: UserShowRouter }); </code></pre> <p>The UserShowRouter looks something like this:</p> <pre><code>UserShowRouter = RouteController.extend({ before: function() { this.subscribe('user', this.params.id).wait(); this.subscribe('userPlaylists', this.params.id).wait(); }, data: function() { var user = Meteor.users.findOne({ 'profile.username': this.params.id }), var playlistsMade = Playlists.find({ 'user.id': user._id }); return { user: user, playlistsMade: playlistsMade, }; }, action: function() { this.render('profile', { to: 'rightbarYield' }); } </code></pre> <p>});</p> <p>A <code>user</code> has several <code>playlists</code>. On the user's profile page the user data and the playlists he owns should be shown.</p> <p>In the before hook I subscribe to the user and to all playlists the user owns. Here are the according publish functions:</p> <pre><code>Meteor.publish('user', function(username) { return Meteor.users.find({ 'profile.username': username }); }); Meteor.publish('userPlaylists', function(username) { return Playlists.find({ 'user.username': username }); }); </code></pre> <p><strong>Following problem occurs:</strong> When I visit the <code>/profile/user</code> page for the first time everything works like a charm. When I change from the <code>/profile/user</code> page to the <code>/</code> (home) page and then back to the <code>/profile/user</code> following exception gets thrown:</p> <pre><code>Exception from Deps recompute: Error: Member already exists: jzJMYRTYjG9FDqHmT at _extend.add (http://localhost:3000/packages/ui.js?b7accb7b6966f638ff085b5d7f310d129aad8c19:1757:17) at Object.ObserveSequence.observe.addedAt (http://localhost:3000/packages/ui.js?b7accb7b6966f638ff085b5d7f310d129aad8c19:3572:15) at Object.diffFn.addedBefore (http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:196:17) at http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:2649:42 at Array.forEach (native) at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?13ab483e8a3c795d9991577e65e811cd0b827997:130:11) at LocalCollection._diffQueryOrderedChanges (http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:2639:5) at diffArray (http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:194:3) at http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:125:11 at Object._.extend.nonreactive (http://localhost:3000/packages/deps.js?34f4906d0a01d1c2873bed712b3bd039da3c9bab:341:14) </code></pre> <p>This problem <strong>does not occur</strong> when I subscribe to all playlists <strong>at the beginning</strong> in my <code>main.js</code> (not in the routeController) <code>Meteor.subscribe('playlists')</code> </p> <p>But this brings along following issue: When I'm not at the <code>profile/user</code> route anymore, but at at the home router <code>/</code> and the data of one of the existing playlists changes (e.g. the title is changed) and the dependency gets recomputed following exception is thrown:</p> <pre><code>Exception in queued task: TypeError: Cannot read property 'data' of null at Object.ObserveSequence.observe.changed (http://localhost:3000/packages/ui.js?b7accb7b6966f638ff085b5d7f310d129aad8c19:3584:52) at Object.cursor.observe.changed (http://localhost:3000/packages/observe-sequence.js?c4bfebff26188a6d7bd7b902bf9ad3e3c87a0f77:137:25) at Object.cursor.observeChanges.changed (http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:1096:19) at http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:349:15 at _.extend.runTask (http://localhost:3000/packages/meteor.js?e2f7aa115469a020bb2030038d4f74b320dc9533:558:11) at _.extend.flush (http://localhost:3000/packages/meteor.js?e2f7aa115469a020bb2030038d4f74b320dc9533:586:10) at _.extend.drain (http://localhost:3000/packages/meteor.js?e2f7aa115469a020bb2030038d4f74b320dc9533:594:12) at LocalCollection.update (http://localhost:3000/packages/minimongo.js?56dbd9be5b85de2aee072a05810b82c155a20d99:638:22) at Object.self._connection.registerStore.update (http://localhost:3000/packages/mongo-livedata.js?2f66d8591aa3225badaf5a98bfba28287bff3a3d:239:30) at Object.store.(anonymous function) [as update] (http://localhost:3000/packages/livedata.js?dab0057c9e7c90bcd874be39d89b9cd54637979b:3583:48) </code></pre> <p>I don't know where the problem lies – with Meteor? with Iron-Router? with my subscriptions or routes? <strong>Any help is highly appreciated! Thanks</strong> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload