Skip to content
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

refactor: Use n0-future in favor of futures-* libraries and tokio::{spawn,task,time} #3156

Merged
merged 11 commits into from
Jan 29, 2025

Conversation

matheus23
Copy link
Member

@matheus23 matheus23 commented Jan 29, 2025

Description

  • replaces all imports of futures_lite, futures_util, futures_sink and futures_buffered with re-exports from n0_future.
  • replaces all imports of std::time with n0_future::time
  • replaces all occurrences of tokio::{spawn,task,time} with n0_future::{spawn,task,time}
  • does not affect tests: we use a bunch of special things there, like tokio::time::advance that we don't have n0-future yet. It's also not strictly necessary for shipping e.g. browser stuff.

The goal of this PR is

  • to get us closer to browser compatibility (I've verified that I've replaced enough of all task spawning, etc. such that mostly cfg-ing out and other unrelated changes remain browser support)
  • to make the diffs of the browser-support PRs easier to follow

Essentially this is work extracted out of the browser PRs.

Breaking Changes

I don't think there are any breaking changes from this.
It's possible that JoinSet or JoinHandle types leak from the interfaces somewhere, but they're identical to the old ones (just re-exports) outside of wasm*-*-unknown targets.

Notes & open questions

I've tried setting up semgrep, but (1) IIUC, setting it up for CI requires that you have an account with them, only running locally is free and (2) I haven't found a way to ignore e.g. std::time imports when you're inside a *::tests module, which means we'd either need to convert all our tests to n0-future or ignore warnings and I think both of these options might suck.

Change checklist

  • Self-review.
  • All breaking changes documented.

@matheus23 matheus23 self-assigned this Jan 29, 2025
@matheus23 matheus23 added this to the v0.32.0 milestone Jan 29, 2025
let republish = tokio::time::sleep(Duration::MAX);
tokio::pin!(republish);
let republish = time::sleep(Duration::MAX);
n0_future::pin!(republish);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the pin macro exists in the std lib

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it doesn't work though. If I use std::pin::pin!(republish) it doesn't compile for me 🤔

We need `flatten_stream`, which isn't re-exported in n0-future.
Copy link

github-actions bot commented Jan 29, 2025

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3156/docs/iroh/

Last updated: 2025-01-29T15:28:14Z

Copy link

github-actions bot commented Jan 29, 2025

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 413095d

@matheus23 matheus23 added this pull request to the merge queue Jan 29, 2025
Merged via the queue into main with commit 617fa50 Jan 29, 2025
26 checks passed
@matheus23 matheus23 deleted the matheus23/n0-future branch January 29, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants