Adopt wasm-bindgen unwind safety enforcement#999
Open
guybedford wants to merge 1 commit into
Open
Conversation
Update wasm-bindgen submodule to pick up unwind safety enforcement on #[wasm_bindgen] exports (wasm-bindgen/wasm-bindgen#5128). Add wasm-streams and gloo as submodules pointing at forks that propagate unwind safety bounds through closures and timers. Patch both via [patch.crates-io] so the worker crate compiles against the new enforcement. Refactor durable object test fixtures to use Cell wrapped in AssertUnwindSafe, replacing RefCell. Cell is single-threaded safe for Copy types because every operation is an atomic move with no borrow guard to leave dangling; AssertUnwindSafe is the narrow, honest assertion for the interior mutability fields without making blanket promises about State/Env. Add cargo url replacement so transitive git deps fetched via SSH fall back to HTTPS for cargo generate users.
Merging this PR will not alter performance
|
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.
This adopts the unwind safety enforcement landed in wasm-bindgen/wasm-bindgen#5128, which adds
MaybeUnwindSafebounds on#[wasm_bindgen]exports and closure types so that types crossing the JS/Rust boundary underpanic=unwindare explicitly unwind safe.Picking up that change required updates in two dependencies, which propagate the bound through their public APIs:
wasm-streams(fix: implement UnwindSafe/RefUnwindSafe for wasm-bindgen exports MattiasBuelens/wasm-streams#35) - implementsUnwindSafe/RefUnwindSafefor the streams wrappersgloo-timers(fix(timers): propagate unwind safety to user callbacks ranile/gloo#562) - propagates unwind safety to user callbacksBoth are added here as submodules pointing at the corresponding fork branches and patched via
[patch.crates-io]until the upstreams land and are published.The durable object test fixtures (
test/src/counter.rs,test/src/durable.rs) hadRefCell<T>fields holdingCopyprimitives. These were refactored toCell<T>wrapped inAssertUnwindSafe:Cell<T: Copy>is genuinely unwind safe in single-threaded wasm - every operation is an atomic move with no borrow guard to leave dangling - but the type system rejects it becauseUnsafeCellhas a blanket negativeRefUnwindSafeimpl.AssertUnwindSafeis the narrow assertion scoped to just the interior-mutability fields rather than a blanketimpl RefUnwindSafeon the durable object structs (which would also be asserting unwind safety on theStateandEnvfields we don't own).Also adds a
.cargo/config.tomlURL replacement so transitive git deps fetched via SSH fall back to HTTPS, useful forcargo generateusers without GitHub SSH set up.Tested via
npm run test-panic-unwind- the panic-unwind build now compiles cleanly and the existing test suite passes (one pre-existing rate_limit test failure unrelated to this change).