Reactive publish using async collection functions

I finally found some time to migrate my old peerlibrary:reactive-publish code to be working with Meteor 3.x by using nachocodoner:reactive-publish 1.1.0-beta.1.

I did encounter some weirdness though:

When I replace my old v2.x ‘colXXX.find(y).forEach()’ loops inside this.autorun() with the new style ‘for await (let d of colXXX.find(y))’ I occasionally get empty query results, so the loop is not executed then. Since my migration to Meteor 3.x earlier this year I use ‘for await (let d of colXXX.find(y))’ everywhere without problems, so it seems like the problem only appears when ‘for await’ is being used during this.autorun() inside the Meteor.publish function. If I replace these loops with ‘await colXXX.find(y).forEachAsync()’ all works fine.

I did experience weird opposite behavior earlier this year though when using nested .forEachAsync() code on the client side, so there I had to use ‘for await’ instead… See my earlier post: Unexpected behavior of (nested) forEachAsync() in client stub - #2 by avijobo

Besides the above, I notice a big difference in performance using reactive-publish against zodern:relay for reactive publications. In my app, one user action may trigger thousands of document updates. To anticipate this I use optimistic UI to get fast client UI responses. Certain user actions cause the UI to be updated in less than a second while the server needs about 20 seconds to process the same thousands of document changes using zodern:relay pipelines, however with reactive-publish the same action takes about 420 seconds on the server! I assume reactive-publish runs this.autorun() every single time a document changes, while zodern:relay postpones and merges multiple document updates thru the pipeline mechanism? I’m not an expert in this matter so I’m not sure what causes this huge difference in delay, but I assume there must be a fundamental difference on how multiple document updates are published to the client in these two packages?

Anyway, just wanted to mention this here, since I am very grateful nachocodoner upgraded the reactive-publish package, however in my use case I’ll keep using zodern:relay for now for performance reasons, despite the occasional exceptions I get with this package. (see my earlier post: Reactive publish using async collection functions - #9 by avijobo)

1 Like