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:
37
37
- uses : actions/checkout@v4
38
38
- name : Install Rust
39
39
run : rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
40
+ - run : rustup target add wasm32-unknown-unknown
40
41
- run : cargo build --all --all-features --all-targets
41
42
if : startsWith(matrix.rust, 'nightly')
42
43
- name : Run cargo check (without dev-dependencies to catch missing feature flags)
43
44
if : startsWith(matrix.rust, 'nightly')
44
45
run : cargo check -Z features=dev_dep
45
46
- run : cargo test
47
+ - run : cargo check --all --all-features --target wasm32-unknown-unknown
46
48
47
49
msrv :
48
50
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -270,7 +270,18 @@ impl<'a> Executor<'a> {
270
270
271
271
/// Returns a reference to the inner state.
272
272
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" )
274
285
}
275
286
}
276
287
You can’t perform that action at this time.
0 commit comments