Skip to content

feat: build on wasm#75

Merged
Frando merged 24 commits intomainfrom
Frando/wasm
Feb 24, 2026
Merged

feat: build on wasm#75
Frando merged 24 commits intomainfrom
Frando/wasm

Conversation

@Frando
Copy link
Copy Markdown
Member

@Frando Frando commented Nov 3, 2025

Description

Make iroh-docs work in WebAssembly in the browser, memstore only.

  • Has the usual changes to use n0-future for time and tasks.
  • redb works in-memory in the browser. No persistent store for now. In native environments, we spawn a separate thread for the storage actor with a single-threaded tokio runtime. In wasm, we instead simply run this on the main thread. With the inmemory store this is fine, IMO.
  • This PR includes a refactor that was needed anyway: A couple of methods on Replica are now async because we previously used send_blocking on a async_channel::Sender (uuh) and async_channel::Sender::send_blocking is not available on wasm.

Breaking Changes

Made a couple of methods on Replica async because we previously used send_blocking on a async_channel::Sender (uuh) and async_channel::Sender::send_blocking is not available on wasm. This is a much needed refactor anyways.

(needs more details)

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@n0bot n0bot bot added this to iroh Nov 3, 2025
@github-project-automation github-project-automation bot moved this to 🏗 In progress in iroh Nov 3, 2025
@Frando Frando force-pushed the Frando/wasm branch 2 times, most recently from 817309b to 42d921f Compare November 3, 2025 13:47
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 3, 2025

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

Last updated: 2026-02-24T12:57:39Z

@Frando Frando marked this pull request as ready for review November 3, 2025 14:55
@Frando Frando changed the title (wip) feat: build on wasm feat: build on wasm Nov 3, 2025
@b5 b5 force-pushed the Frando/wasm branch 2 times, most recently from dfd62c8 to 061ece7 Compare November 10, 2025 20:51
@b5
Copy link
Copy Markdown
Member

b5 commented Nov 10, 2025

I've taken the liberty of updating this PR, all of the upstream PRs this one depends on are now merged, we're only waiting on a release for n0-future that'll include the features this relies on.

@matheus23
Copy link
Copy Markdown
Member

n0-future 0.3.1 is released now ✌️

@Frando
Copy link
Copy Markdown
Member Author

Frando commented Nov 11, 2025

Updated to use the n0-future release. I think this is ready for merge now :)

@b5
Copy link
Copy Markdown
Member

b5 commented Nov 11, 2025

TIL if you import std::time::{Duration, Instant}, it'll compile to wasm, but browsers get very upset when either of those are used.

Pushed what is hopefully a fix, but ideally we'd have a CI check that ensures we use the n0_future::time:: variants when targeting browser wasm

@b5
Copy link
Copy Markdown
Member

b5 commented Nov 11, 2025

speaking of references to std::time: n0-computer/iroh-blobs#194

@robcohen
Copy link
Copy Markdown

robcohen commented Feb 9, 2026

Excited to see this land! I'm building a P2P sync library for Obsidian (note-taking app) and have been designing around the iroh-docs API so we can swap it in once WASM support is ready. Looking forward to using native range reconciliation instead of our custom Prolly tree sync. 🎉

cbenhagen added a commit to cbenhagen/iroh-docs that referenced this pull request Feb 20, 2026
Resolve merge conflicts from rebasing the wasm support PR onto
v0.96.0 main:
- Cargo.toml: update dep versions to 0.96 era, keep default-features=false
  and optional quinn from wasm PR
- tests/util.rs: use IntoAddressLookup (0.96 API) with Storage enum and
  n0_future::time from wasm PR
- ci.yaml: keep main's docs-rs approach, keep wasm_build job from PR
- Cargo.lock: regenerated
cbenhagen added a commit to cbenhagen/iroh-docs that referenced this pull request Feb 20, 2026
Make iroh-docs compile for wasm32-unknown-unknown (browser, memstore only).

- Use `default-features = false` on iroh, iroh-blobs, iroh-gossip, irpc
  to exclude non-wasm-compatible code paths
- Make quinn optional, gated behind `rpc` feature
- Use n0_future::time instead of std::time for browser compatibility
- Add cfg_aliases build script for `wasm_browser` convenience cfg
- Add wasm build CI job
- Several methods on `Replica` are now async (previously used
  send_blocking which is unavailable on wasm)

Based on n0-computer#75, updated for iroh 0.96.
cbenhagen added a commit to cbenhagen/iroh-docs that referenced this pull request Feb 20, 2026
Resolve merge conflicts from n0-computer#75 against v0.96:
- Update dependency versions to 0.96 era, keep default-features=false
- Use IntoAddressLookup API (renamed from IntoDiscovery in 0.96)
- Keep main's docs-rs CI approach
- Regenerate Cargo.lock
cbenhagen added a commit to cbenhagen/iroh-docs that referenced this pull request Feb 20, 2026
Resolve merge conflicts from n0-computer#75 against v0.96:
- Update dependency versions to 0.96 era, keep default-features=false
- Use IntoAddressLookup API (renamed from IntoDiscovery in 0.96)
- Keep main's docs-rs CI approach
- Regenerate Cargo.lock
- Update dependency versions to 0.96 era, keep default-features=false
- Drop iroh-blobs git dep, use released v0.98
- Use IntoAddressLookup API (renamed from IntoDiscovery in 0.96)
- Keep main's docs-rs CI approach
- Regenerate Cargo.lock
@cbenhagen
Copy link
Copy Markdown
Contributor

@Frando I opened #84 to resolve the merge conflicts with main (v0.96). Hope that helps unblock this PR!

Copy link
Copy Markdown
Member

@b5 b5 left a comment

Choose a reason for hiding this comment

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

🙌🙌🙌

@Frando Frando merged commit bf1fc32 into main Feb 24, 2026
25 checks passed
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in iroh Feb 24, 2026
@Frando Frando mentioned this pull request Mar 13, 2026
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.

5 participants