-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indirection/abstraction over tokio::spawn
and friends
#2979
Comments
sane is the word you are looking for... |
Perhaps worth keeping in mind that I highly doubt it but perhaps we should spend a couple of minutes thinking about if there's a good solution for this problem once we get to this issue. |
From what I can see this is now the last issue to get webassembly support for iroh-net as outlined in #2799 Is there a plan to do this? :) |
@TotalKrill happy to see people so interested in this :) As I wrote in the issue:
So even if this lands, there will be more work required. It's just us keeping track of things to make sure we have a rough overview. But to answer the actual question, yes, you can see the module that implements this indirection in the If you want to, you're free to depend on this branch yourself and start to play with iroh in browsers - it works with the default public relays we have deployed as well. You can see me playing and testing that branch over here as well: https://github.com/matheus23/browser-iroh-net-demo/blob/update/Cargo.toml Possibly very soon we'll have a demo branch that's easier to set up for all folks interested to play with. |
Iroh's use of
tokio
is very particular/opinionated.tokio::spawn
without wrapping theJoinHandle
withAbortOnDropHandle
JoinSet::spawn
without some loop somewhere callingtasks.join_next().await, if !tasks.is_empty()
(to avoid leaking memory from task results accumulating) (EDIT: this might only be necessary if used withelse
insidetokio::select!
, see refactor(iroh, iroh-relay): JoinSet disabling in tokio::select! #3052 )spawn
must use an.instrument()
for tracing.Furthermore, for iroh in the browser (#2799) we will need to abstract away all
tokio::spawn
usage because it's not available in the browser! (I've already implemented aJoinSet
alternative on top ofwasm_bindgen_futures
for exactly that reason)Given that such an indirection would have to be created for the browser work anyways, this might be a good opportunity to introduce an API at that indirection that avoids all of the above footguns (forgetting
.instrument()
, leaking tasks, leaking memory).The text was updated successfully, but these errors were encountered: