Publish with composite - Weird behavior

Hi,

I have two collections : Artworks & ArtworksFavorites
The first is not complicated to understand. And the second is a collection to create relation between user and artworks (e.g. likes on facebook).

{
     _id,
     user,
     artwork
}

I have two pages.
one page with a subscription to somes artworks. But this sub use publish-composite to get the artworks that users liked.

Meteor.publishComposite('artwork_favorites.ofUser', function (userId, limit) {
        return {
            find: function () {
                const selector = {
                    user: userId
                };
                const options = {
                    limit: limit || 10,
                }
                return ArtworkFavorites.find(selector, options);;
            },
            children: [
                {
                    find: function (fav) {
                        const options = {
                            fields: {
                                image: 1,
                                title: 1,
                                year: 1,
                                slug: 1,
                                createdAt: 1,
                                owner : 1
                            },
                            sort: {
                                createdAt: -1
                            }
                        }
                        return Artworks.find({
                            _id: fav.artwork
                        }, options)
                    }
                }
            ]
        }
    });

You can see that I don’t publish all data for the artwork object.
On this page, all is good, I have the good information.

When I click on an artwork on the first page, I want to be redirect to the detail view of the artwork. So with more information.

On the second page I have a sub that expose all data from an artwork.

Meteor.publish('artworks.one', function (slug) {
        const selector = {slug: slug};
        const options = {};
        return Artworks.find(selector, options);
    });

But Meteor.subscribe('artworks.one', slug).ready() is true without all data, but with the previous set of fields. So in the minimongo collection I have only one artwork but without the other fields.

The problem occured only if the previous page have a subscription with publish composite.

When I have a page with a normal pub, with a Meteor.publish without relations, the sub for the second page is good.

With all my tests, I sure that is the publish composite which do this error.

Have you got some idea about that ?

Thanks :slight_smile:

PS : I use Astronomy package for my collections.

EDIT : OK, so it’s a bug between Astronomy and publish-composite
If I use the Collection Class from Astronomy, the bug appear. But the normal mongo collection it’s disappear.
I open an issue on both repo.

EDIT2 : See https://github.com/jagi/meteor-astronomy/issues/576 for explanation.