Skip to content

Commit b374f69

Browse files
wip: JSPI awaiting JS bug
1 parent bef2125 commit b374f69

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

crates/js-component-bindgen/src/function_bindgen.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,13 +1230,7 @@ impl Bindgen for FunctionBindgen<'_> {
12301230
Instruction::IterBasePointer => results.push("base".to_string()),
12311231

12321232
Instruction::CallWasm { name, sig } => {
1233-
let get_or_create_async_state_fn = self.intrinsic(Intrinsic::Component(
1234-
ComponentIntrinsic::GetOrCreateAsyncState,
1235-
));
1236-
let current_task_get_fn =
1237-
self.intrinsic(Intrinsic::AsyncTask(AsyncTaskIntrinsic::GetCurrentTask));
12381233
let debug_log_fn = self.intrinsic(Intrinsic::DebugLog);
1239-
12401234
uwriteln!(
12411235
self.src,
12421236
"{debug_log_fn}('{prefix} [Instruction::CallWasm] enter', {{
@@ -1251,8 +1245,6 @@ impl Bindgen for FunctionBindgen<'_> {
12511245
has_post_return = self.post_return.is_some(),
12521246
);
12531247

1254-
let component_instance_idx = self.canon_opts.instance.as_u32();
1255-
12561248
// Inject machinery for starting a 'current' task
12571249
self.start_current_task(
12581250
inst,

crates/js-component-bindgen/src/transpile_bindgen.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3694,8 +3694,13 @@ impl<'a> Instantiator<'a, '_> {
36943694
uwriteln!(self.src.js, "let {local_name};");
36953695
self.bindgen
36963696
.all_core_exported_funcs
3697-
// NOTE: we need
3698-
.push((core_export_fn.clone(), requires_async_porcelain || is_async));
3697+
// NOTE: this breaks because using WebAssembly.promising and trying to
3698+
// await JS from the host is a bug ("trying to suspend JS frames")
3699+
//
3700+
// We trigger this either with --async-imports *OR* by widening the check as below
3701+
//
3702+
// .push((core_export_fn.clone(), requires_async_porcelain || is_async));
3703+
.push((core_export_fn.clone(), requires_async_porcelain));
36993704
local_name
37003705
}
37013706
};

packages/jco/test/p3/ported/wasmtime/component-async/post-return.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ suite('post-return async sleep scenario', () => {
8787
transpile: {
8888
extraArgs: {
8989
minify: false,
90+
asyncImports: [
91+
// NOTE: without this async import specified, attempting to
92+
// sleep across JS frames will fail.
93+
'local:local/sleep#sleep-millis',
94+
],
9095
}
9196
},
9297
});

0 commit comments

Comments
 (0)