Iām not familiar with Meteor internals, but prima facie I expect it to be quite a major work, almost a rewrite of all code thatās coupled with fibers
. Thatās why I made the suggestion only in the context of Meteor 2.0.
Every API that hides the asynchronous execution would have to be changed to be Promise
-based. So
const user = Meteor.users.findOne();
might become
(async () => {
const user = await Meteor.users.findOne();
})(); // framework may support top level `await` but let's skip the nitty-gritties iin this discussion
or its equivalent:
Meteor.users.findOne().then(user => {})
Hopefully there would be a way to make the current fibers
approach an opt-in, maybe via a package. Somebody familiar with how fibers
are used internally might be able to tell how backward compatible that could be made. But if thatās not feasible, it shouldnāt stop this evolution; then Meteor 2.0 could be a recommendation for new apps while current apps could stay with 1.x and gradually migrate if worth it for that individual project.
Well, āmanyā might be subjective, but I think there are enough to warrant a revisit of the decision. More importantly itās the nature of those issues. And perhaps even more importantly, any such problem is doomed to be specific to Meteor; the rest of the Node.js community is unlikely to find any incentive in fixing them. See the example I shared earlier.
Today, this problem can be considered āsolvedā in Node.js because of async
/await
. Since Meteor is not a language, but rather a framework on Node.js, it would be better to defer to Javascript/Node.js standards where feasible ā if we were to apply the principle of least astonishment here. A newcomer is more likely to read about Node.js first than Meteor.js, right?
Sure thatās the decision to be made, and I hope the points Iām putting forth would help with that. I have come to conclude that while adopting fibers
was likely a good decision at the time, it has become a technical debt considering the current state of Node.js and its ecosystem, and of course also considering the current state of Meteor.js.
I donāt think he said coroutines
is ābetterā than async
/await
, just that with coroutines
we wonāt need those separate keyword. But forward to today, we have those separate keywords as part of the language itself! And coroutines may never become a standard in JS (for good reasons).
Iāve explained my take from his presentation earlier; pasted below is the part that addresses the specific points you raise here:
My point is not whether coroutines are ābetterā as a concept. My simple submission is: is Meteor still compelled to live with the tradeoffs of using fibers
? If Meteor were to be written from the ground up today, would one have still used fibers
? I reckon that removing fibers
would not only eliminate the technical debt whose interest has to be paid in the form of the kind of issues I listed earlier, but also help with the adoption and community contribution.