8000 ci: test and lint the wasm32 targets again; fix browser panics and dropped pages by adityamukho · Pull Request #469 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

ci: test and lint the wasm32 targets again; fix browser panics and dropped pages - #469

Merged
adityamukho merged 2 commits into
v3from
chore/wasm32-test-build
Oct 7, 2026
Merged

adityamukho merged 2 commits into
v3from
chore/wasm32-test-build

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

The repo split (#231, 2026-05-17) deleted wasm-browser.yml and wasm-wasi.yml. Those jobs ran core's own wasm tests: wasm-pack test --headless in Chrome and Firefox, and cargo test --target wasm32-wasip1 under Wasmtime. minigraf-wasm's CI only builds the package, so nothing replaced them. Native clippy never sees src/browser/, which only compiles for wasm32. Since May the wasm32 test build broke (fixed on v3 in #468), and these problems piled up:

CI

New .github/workflows/wasm.yml, on pushes and PRs to main and v*:

  • browser: wasm-pack test --headless --{firefox,chrome} --features browser
  • wasi: cargo test --target wasm32-wasip1 --lib --tests under Wasmtime v49.0.2 with --dir . for fixtures, plus a build of the REPL binary
  • clippy: cargo clippy --target {wasm32-unknown-unknown --features browser, wasm32-wasip1} -- -D warnings

Test build

  • 7 file-backed integration test files had no #![cfg(not(target_arch = "wasm32"))], unlike the other 20: concurrency_test, cursor_test, error_codes_{foundation,storage,wal}_test, fact_log_test, log_writer_test. examples/pid_ns_helper.rs now has a stub main on wasm32, like the other examples.
  • 8 tests spawn threads (6 lock-poisoning tests, udf_test::thread_safety) or a child process (repl::run_public_method_exits_on_non_tty_stdin). WASI can do neither, and a wasm panic aborts the whole run. They are #[cfg_attr(target_os = "wasi", ignore = "...")].

Browser fixes (all found by running clippy on the real target)

  • Dirty pages silently dropped: checkpoint, importGraph and every write flushed dirty pages to IndexedDB via .filter_map(|id| read_page_raw(id).ok() …). A page that failed to read was left out of the flush, and the call still succeeded. A shared take_dirty_pages now returns the error.
  • Panics in the browser layer: unwrap() in the IndexedDB upgradeneeded callback, on the IndexedDB handle, and on the page-buffer lock. On wasm32 a panic aborts the whole instance. The callback now can't fail loudly: a store that wasn't created makes the first transaction return an error instead. The handle code uses Option directly, and the lock uses PoisonError::into_inner (wasm32 aborts on panic, so the lock is never poisoned).
  • Casts: IndexedDB keys must be whole numbers in 0..=2^53, otherwise they're an error rather than truncated (2 new tests). The export size is checked. tx_id.cast_signed() matches native. js_sys::Date::now() gets a justified allow.
  • Tests that never ran: the 9 BrowserBufferBackend tests used #[test], which the wasm runner never runs. They now use #[wasm_bindgen_test] and pass.

Warning-free wasm32 builds

wal, storage::verify, storage::dir_sync and the file-only PersistentFactStorage methods are no longer compiled for wasm32, which has no file backend. That removes the ~35 dead-code warnings. The unused BrowserBufferBackend re-export is gone too.

Results (local)

  • Native: cargo test 1,337 passed, 9 ignored (unchanged); fmt and clippy --all-features -D warnings clean.
  • Browser (headless Firefox, wasm-pack test): 23 passed. Chrome runs in CI only.
  • WASI (Wasmtime 49.0.2): 935 passed, 9 ignored, all test targets.
  • Clippy -D warnings: 0 findings on both wasm targets.

main (v2.x) has the same broken test build: the duplicate page_cache_capacity and the dir_sync gate. These are test-infrastructure fixes, not data-integrity fixes, so per the support policy they stay on v3. The dropped-page bug in BrowserDb also exists on v2.x.

🤖 Generated with Claude Code

https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn

…opped pages

The repo split (#231) moved the browser and WASI CI jobs to
minigraf-wasm, which only builds the package. Core's own wasm tests
stopped running and the wasm32 test build broke unnoticed.

- New .github/workflows/wasm.yml: wasm-pack test in headless Firefox
  and Chrome; unit and integration tests on wasm32-wasip1 under Wasmtime;
  clippy -D warnings on both wasm targets.
- Gate the seven file-backed integration test files that lacked
  #![cfg(not(target_arch = "wasm32"))], and pid_ns_helper's main.
- Ignore on WASI the eight tests that spawn threads or a child process.
- BrowserDb: a dirty page that cannot be read is now an error instead of
  being skipped from the IndexedDB flush while reporting success. No
  unwrap() in the IndexedDB upgrade callback, the backend handle or the
  page-buffer lock (a wasm32 panic aborts the instance). IndexedDB keys
  that are not whole page numbers are rejected, not truncated.
- The nine BrowserBufferBackend tests used #[test], which the wasm test
  runner never runs; they are #[wasm_bindgen_test] now and pass.
- wal, storage::verify and storage::dir_sync, and the file-only
  PersistentFactStorage methods, are not compiled for wasm32, so the
  wasm32 builds have no warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn
@codecov
codecov Bot commented Oct 7, 2026 •
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

PersistentFactStorage::with_backend and with_backend_mut exist only for
wasm32 with the browser feature, but tarpaulin counted their lines in the
native coverage report as uncovered (codecov/patch failed on #469). They
now live in a child module, storage/persistent_facts/browser_access.rs,
that only browser builds compile, like src/browser itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn
@adityamukho
adityamukho merged commit a9ca575 into v3 Oct 7, 2026
24 checks passed
@adityamukho
adityamukho deleted the chore/wasm32-test-build branch October 7, 2026 06:59
adityamukho added a commit that referenced this pull request Oct 7, 2026
…the IndexedDB flush (#470)

checkpoint(), importGraph() and every write collected dirty pages with
read_page_raw(id).ok() in a filter_map, so a page that failed to read
was silently left out of the flush to IndexedDB while the call reported
success. A shared take_dirty_pages helper (the same one v3 has since
#469) now returns the read error.

No current path leaves a dirty id without a page (ids enter the dirty
set only after the page is stored), so this is defensive rather than a
fix for observed loss.

The browser unit tests did not compile on wasm32 (a duplicate
page_cache_capacity from #341/#342, and dir_sync tests using tempfile);
both are fixed so the two new regression tests run.


Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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

0