meteor / meteor/blaze

Not rendering helper if collection "hidden" beside Promise

Open
#473 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
543
Forks
117
Avg merge
6h 18m
Merged PRs (30d)
2

Description

If you make a simple async helper in conjuction with a meteor collection, during the sync of the collection, the helper is not updated.

I expect the helper to be refreshed once the collection is synced.

- Blaze: `3.0.1`
- Meteor: `3.0.2`

Here is a small code that you explain better the issue.
If you move up the line of `find.fetch` before the async call it's working as expected.
```js
Template.Home.onCreated(() => {
Tracker.autorun(async () => {
const user = await Meteor.userAsync();
Meteor.subscribe('projects', [user?.someProp]); // Help sync Project Meteor Collection
})
})

Template.Home.helpers({
// This is not working as expected
async someHelper(): Promise {

const someAsyncCall = await myFunction();
if (someAsyncCall) {
const projects = Project.find({}).fetch();
console.log(projects.length) // Always 0
return 'yeah';
}

return ''
}
// This is working as expected
async someHelperWorking(): Promise {

const someAsyncCall = await myFunction();
const projects = Project.find({}).fetch();
if (someAsyncCall) {
console.log(projects.length) // Always 10 (The amount subscribed)
return 'yeah';
}

return ''
}
})
```

Tell me if you need more information.

Contributor guide

Open the contributing guide

Research direction

Start by running the provided Blaze 3.0.1 and Meteor 3.0.2 reproduction, comparing the two helpers and the placement of Project.find({}).fetch(). Trace when the async helper is evaluated relative to collection synchronization, then add a regression test showing that the helper refreshes after the subscribed collection is populated.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.