laverdet / node-fibers

Fiber/coroutine support for v8 and node.
MIT License
3.56k stars 224 forks source link

Question: node-fibers API using async/await #443

Open meggarr opened 4 years ago

meggarr commented 4 years ago

Hello,

With respects to node-fibers, I have been using Meteor JS for several month. MeteorJS gave me a lot of convenience to develop webapps. I noticed that OBSOLESCENCE NOTICE that new projects should use async/await instead of node-fibers. This means for projects like Meteor, it will need an effort to refactor and move to async/await. I am not sure if there's an easier way that can implement node-fibers API using async/await features, if that can be done, it will help Meteor to async/await easily.

Thanks and regards,

laverdet commented 4 years ago

The fact is that the JS ecosystem as a whole has overwhelmingly chosen async/await over fibers. There may still be a niche community for fibers but my opinion is that it is a mistake to write new code which depends on fibers. Like I mentioned in the note, I will continue to support fibers for as long as technically possible-- so Meteor users don't need to panic. Obsolescence is actually the longest of the stages of software lifecycle 😇

opyh commented 3 years ago

@laverdet I have to admit I panic a bit: more node modules are beginning to use WASM+GC, which isn't working with fibers. Using them leads to to 'archived threads in combination with wasm not supported' errors. From my understanding, the only 'workaround' so far is to switch off WASM+GC which causes another issue (exploding RAM usage).

Do you have any pointers how we could fix this?

Is there an alternative way to keep fibers functionality without 'hacking the thread-local storage to trick V8 into thinking it's running separate threads/isolates' (Quote source)?

laverdet commented 3 years ago

@opyh this error message comes directly from v8 -- https://github.com/v8/v8/commit/e937bc5ed6b80851e8b0471dbc41d1ee4990d29a

v8 sees fibers as archived threads, there's frankly no way around it. You will need to track down someone on the v8 team and convince them to implement what looks to be a major feature.