Skip to content

Commit 334f98a

Browse files
wip: fix async function specification
1 parent b374f69 commit 334f98a

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ pub(crate) fn requires_async_porcelain(
298298
let name = match func {
299299
FunctionIdentifier::Fn(func) => func.name.as_str(),
300300
FunctionIdentifier::CanonFnName(name) => name,
301-
};
301+
}
302+
.trim_start_matches("[async]");
302303

303304
if async_funcs.contains(name) {
304305
return true;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3697,7 +3697,7 @@ impl<'a> Instantiator<'a, '_> {
36973697
// NOTE: this breaks because using WebAssembly.promising and trying to
36983698
// await JS from the host is a bug ("trying to suspend JS frames")
36993699
//
3700-
// We trigger this either with --async-imports *OR* by widening the check as below
3700+
// We trigger this either with --async-exports *OR* by widening the check as below
37013701
//
37023702
// .push((core_export_fn.clone(), requires_async_porcelain || is_async));
37033703
.push((core_export_fn.clone(), requires_async_porcelain));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ export async function buildAndTranspile(args) {
4646
jco: {
4747
transpile: {
4848
extraArgs: {
49+
asyncExports: ['local:local/run#run'] ,
4950
...(args.transpile?.extraArgs || {}),
50-
asyncExports: ['local:local/run#run'],
5151
},
5252
},
5353
},

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,14 @@ suite('post-return async sleep scenario', () => {
8888
extraArgs: {
8989
minify: false,
9090
asyncImports: [
91-
// NOTE: without this async import specified, attempting to
92-
// sleep across JS frames will fail.
91+
// Provided by the host
9392
'local:local/sleep#sleep-millis',
9493
],
94+
asyncExports: [
95+
// NOTE: Provided by the component, but *does* trigger calling
96+
// of the host-provided async improt
97+
'local:local/sleep-post-return#run',
98+
],
9599
}
96100
},
97101
});

0 commit comments

Comments
 (0)