Skip to content

Commit

Permalink
feat(iroh-relay): Make the client side of iroh-relay compile & run …
Browse files Browse the repository at this point in the history
…in browsers (#3119)

## Description

<!-- A summary of what this pull request achieves and a rough list of
changes. -->
Allows compiling and running `iroh-relay` in browsers (as long as the
`server` feature is disabled).

By default uses websockets to connect to relays when compiling for the
`wasm32-unknown-unknown` target.
If configured to `Protocol::Relay` specifically, it'll error out.

Test it yourself: `cargo rustc -p iroh-relay --no-default-features
--target=wasm32-unknown-unknown --crate-type=cdylib`

## Breaking Changes

- iroh: `iroh-quinn` re-exports are now updated from version 0.12 to
version 0.13

## Notes & open questions

**Note:** This updates *all* crate's versions to `iroh-quinn` 0.13!
(Because we need them to be consistent between crates in this
workspace.)

## TODO

- [x] Add CI check to make sure the built .wasm is `(import "env"
...)`-free
- [x] Need a new release of `iroh-quinn` with my browser PR in
- [x] ~~**Blocking this from merging**: Need a new `netwatch` release
with the `quinn-udp = "0.5.5"` version bound relaxed~~ it's already
relaxed

## Change checklist

- [x] Self-review.
- [x] All breaking changes documented.
  • Loading branch information
matheus23 authored Jan 28, 2025
1 parent a8d058f commit 03e3e3c
Show file tree
Hide file tree
Showing 20 changed files with 775 additions and 563 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,21 @@ jobs:
- name: Add wasm target
run: rustup target add wasm32-unknown-unknown

- name: Install wasm-tools
uses: bytecodealliance/actions/wasm-tools/setup@v1

- name: wasm32 build (iroh-base)
run: cargo build -p iroh-base --all-features --target wasm32-unknown-unknown
run: cargo build --target wasm32-unknown-unknown -p iroh-base --all-features

- name: wasm32 build (iroh-relay)
run: cargo build --target wasm32-unknown-unknown -p iroh-relay --no-default-features

# If the Wasm file contains any 'import "env"' declarations, then
# some non-Wasm-compatible code made it into the final code.
- name: Ensure no 'import "env"' in iroh-relay Wasm
run: |
! wasm-tools print --skeleton target/wasm32-unknown-unknown/debug/iroh_relay.wasm | grep 'import "env"'

check_semver:
runs-on: ubuntu-latest
Expand Down
Loading

0 comments on commit 03e3e3c

Please sign in to comment.