Repository navigation
Build for WebAssembly (wasm32-wasip2) - #51
Merged
Merged
Conversation
The library builds for wasm32-wasip2 with its default features and runs under wasmtime: the native API, the YAML interpreter and the Redb store. - A `blocking` module runs #[task(blocking)] tasks and Redb's operations on tokio's blocking pool, or where they are called on wasm, which has no threads. It also reads files, so tokio's `fs` feature is no longer needed. - Dependencies that need an operating system (reqwest, sqlx, axum, tonic and the gRPC crates, bollard, openapiv3-extended, jsonschema) are declared for non-wasm targets only, with tokio's `process` and `rt-multi-thread`. - Left out on wasm: ctx.run_shell/run_script/run_container/http (not compiled), and YAML `run: shell`, `run: script`, `call: http` and remote catalogs (they fail with "... is not available on wasm"). - Building for wasm with sqlite, postgres, docker, http-listener, grpc-listener or openapi stops with a message that names the feature. - `just wasm` and a `WebAssembly (WASI)` CI job check the library for the target and run example programs under wasmtime. Specs: platform/wasm.feature (17 scenarios) builds the programs under tests/wasm for wasm32-wasip2 and runs them with wasmtime; they are skipped without the target and wasmtime. New guide chapter `guide::wasm`. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
jackdaw can now be a dependency of a program that compiles to
wasm32-wasip2(wasmtime, Spin, wasmCloud). With the default features it builds and runs: the native API, the YAML interpreter and the Redb store work there. The browser target (wasm32-unknown-unknown) is not covered.blockingmodule runs#[task(blocking)]tasks and every Redb operation on tokio's blocking pool, or, on wasm, where they are called. It also reads files, so tokio'sfsfeature is no longer needed.reqwest,sqlx,axum,tonicand the gRPC crates,bollard,openapiv3-extendedandjsonschemaare declared for non-wasm targets, together with tokio'sprocessandrt-multi-thread.ctx.run_shell,ctx.run_script,ctx.run_containerandctx.httpare not compiled there.run: shell,run: script,call: httpand remote catalogs fail with "… is not available on wasm".sqlite,postgres,docker,http-listener,grpc-listeneroropenapistops with an error that names the feature.just wasmlints the library for the target across six feature sets and runs the@wasmspecs. A newWebAssembly (WASI)CI job runs it, andJACKDAW_REQUIRE_WASMmakes a missing wasmtime or target fail the job instead of skipping.guide::wasmchapter, plus README, CONTRIBUTING and CHANGELOG updates.Native builds
Nothing changes for native users, except that tokio's
rt-multi-threadfeature is now always enabled on native targets (it adds no crates, andyamlno longer asks for it), and tokio'sfsfeature is no longer enabled. The semver check, MSRV build andcargo denyare clean.Tests
The specs were written before the implementation.
platform/wasm.featurehas 17 scenarios; each builds a small program fromjackdaw/tests/wasmforwasm32-wasip2and runs it under wasmtime:forkand calls actually ran;Steps 2 and 4 of the plan passed as soon as the step before them was done, without work of their own. The scenarios were checked to fail on a wrong expectation.
Results: all 376 lib scenarios, CTK 21, listener 8, nested 3, lib 57, Rust API 76 and doctests 53 pass. Clippy is clean for each feature alone and for the full set.
Notes for review
just wasm, exit 0), but thebytecodealliance/actions/wasmtime/setup@v1action and the cacheworkspacesentry can only be checked by this PR's run.durableengine/graph.rs::build_graphonly creates sequential edges if no task in the workflow has athen, so mixingswitchorthen:with plain tasks ends the workflow early. It is unrelated to wasm. The new YAML workflows are written around it.🤖 Generated with Claude Code