You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Async hooks dont wait for the hook to return to perform the Collection op, for example.
To Reproduce
Tickets.before.insert(asyncfunctionticketsBeforeInsert(userId,doc){doc.idNumber=awaitincrementCounter(`PQR::${doc.orgId}`);});console.log(doc.idNumber)// This will be undefined
Expected behavior
Async hooks should await for the response before calling the collection op.
Additional context
Happens in all of the package versions.
Workaround
In a Meteor version before 3.0 you can just use Promise.await
Possible way to fix it
When we call the aspect function callbacks (hooks) we should await them, this will require to use async on CollectionHooks.defineAdvice and to use await Promise.all on each aspect.
For example, this are the changes done to the insert advice:
We, the Members of Meteor Community Packages take every issue seriously.
Our goal is to provide long-term lifecycles for packages and keep up
with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.
However, we contribute to these packages mostly in our free time.
Therefore, we can't guarantee you issues to be solved within certain time.
If you think this issue is trivial to solve, don't hesitate to submit
a pull request, too! We will accompany you in the process with reviews and hints
on how to get development set up.
Please also consider sponsoring the maintainers of the package.
If you don't know who is currently maintaining this package, just leave a comment
and we'll let you know.
@StorytellerCZ any ideas where to look? I fiddled around with it yesterday with no luck. I think one of the possibilities to fix this is to only support this use case in Async methods, so I added a new insertAsync advice, but it never gets called.
Describe the bug
Async hooks dont wait for the hook to return to perform the Collection op, for example.
To Reproduce
Expected behavior
Async hooks should await for the response before calling the collection op.
Additional context
Happens in all of the package versions.
Workaround
In a Meteor version before 3.0 you can just use Promise.await
Possible way to fix it
When we call the aspect function callbacks (hooks) we should await them, this will require to use async on
CollectionHooks.defineAdvice
and to useawait Promise.all
on each aspect.For example, this are the changes done to the insert advice:
The issue with this is that this makes the collection methods to be async too and test will fail.
Any ideas on how to approac this issue will be appreciated.
Related issues
#71
The text was updated successfully, but these errors were encountered: