Skip to content

ci(wasip2): document and test wasm32-wasip2 support (Postgres + MySQL)#4309

Open
ricochet wants to merge 1 commit into
transact-rs:mainfrom
ricochet:wasip2
Open

ci(wasip2): document and test wasm32-wasip2 support (Postgres + MySQL)#4309
ricochet wants to merge 1 commit into
transact-rs:mainfrom
ricochet:wasip2

Conversation

@ricochet

@ricochet ricochet commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

SQLx already runs on wasm32-wasip2 with no library changes: the standard runtime-tokio feature works there because Tokio's net driver builds on WASI via mio. Pooling, LISTEN/NOTIFY, timeouts, and rustls TLS all work. Building for the target requires --cfg tokio_unstable and a current-thread runtime (WASI has no threads in wasip2 target).

This exercises that support:

  • README: add a WebAssembly (wasm32-wasip2) section covering the runtime-tokio setup, the two target requirements, what works, and the remaining limitations (hostname lookup needs --allow-ip-name-lookup, native-tls is unavailable, MySQL caching_sha2 over plaintext needs
    mysql-rsa).
  • examples/wasip2/{postgres,mysql}: runnable pool examples that do a real round-trip — create a table, insert rows in a transaction with bind parameters, read them back ranked, and aggregate. A shared .cargo/config.toml sets --cfg tokio_unstable so a plain cargo build --target wasm32-wasip2 works.
  • CI: a wasip2 job builds both examples and runs them under Wasmtime against Postgres and MySQL service containers, asserting the query output to catch wasm-specific decode regressions.

SQLx already runs on wasm32-wasip2 with no library changes: the standard
`runtime-tokio` feature works there because Tokio's `net` driver builds on
WASI via mio. Pooling, LISTEN/NOTIFY, timeouts, and rustls TLS all work.
Building for the target requires `--cfg tokio_unstable` and a current-thread
runtime (WASI has no threads in wasip2 target).

This documents and exercises that support:
- README: add a WebAssembly (`wasm32-wasip2`) section covering the
  `runtime-tokio` setup, the two target requirements, what works, and the
  remaining limitations (hostname lookup needs `--allow-ip-name-lookup`,
  native-tls is unavailable, MySQL caching_sha2 over plaintext needs
  `mysql-rsa`).
- examples/wasip2/{postgres,mysql}: runnable pool examples that do a real
  round-trip — create a table, insert rows in a transaction with bind
  parameters, read them back ranked, and aggregate. A shared
  `.cargo/config.toml` sets `--cfg tokio_unstable` so a plain
  `cargo build --target wasm32-wasip2` works.
- CI: a `wasip2` job builds both examples and runs them under Wasmtime
  against Postgres and MySQL service containers, asserting the query
  output to catch wasm-specific decode regressions.

Signed-off-by: Bailey Hayes <bailey@cosmonic.com>
@ricochet

Copy link
Copy Markdown
Contributor Author

CI on main is failing. Created a PR to fix: #4311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant