File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,14 @@ jobs:
3737 - uses : actions/checkout@v4
3838 - name : Install Rust
3939 run : rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
40+ - run : rustup target add wasm32-unknown-unknown
4041 - run : cargo build --all --all-features --all-targets
4142 if : startsWith(matrix.rust, 'nightly')
4243 - name : Run cargo check (without dev-dependencies to catch missing feature flags)
4344 if : startsWith(matrix.rust, 'nightly')
4445 run : cargo check -Z features=dev_dep
4546 - run : cargo test
47+ - run : cargo check --all --all-features --target wasm32-unknown-unknown
4648
4749 msrv :
4850 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -270,7 +270,18 @@ impl<'a> Executor<'a> {
270270
271271 /// Returns a reference to the inner state.
272272 fn state ( & self ) -> & Arc < State > {
273- self . state . get_or_init_blocking ( || Arc :: new ( State :: new ( ) ) )
273+ #[ cfg( not( target_family = "wasm" ) ) ]
274+ {
275+ return self . state . get_or_init_blocking ( || Arc :: new ( State :: new ( ) ) ) ;
276+ }
277+
278+ // Some projects use this on WASM for some reason. In this case get_or_init_blocking
279+ // doesn't work. Just poll the future once and panic if there is contention.
280+ #[ cfg( target_family = "wasm" ) ]
281+ future:: block_on ( future:: poll_once (
282+ self . state . get_or_init ( || async { Arc :: new ( State :: new ( ) ) } ) ,
283+ ) )
284+ . expect ( "encountered contention on WASM" )
274285 }
275286}
276287
You can’t perform that action at this time.
0 commit comments