@@ -712,6 +712,9 @@ impl JsBindgen<'_> {
712712 FunctionKind :: AsyncStatic ( _id) => todo ! ( ) ,
713713 } ;
714714
715+ // All imports are sync
716+ let requires_async_porcelain = false ;
717+
715718 // imports are canonicalized as exports because
716719 // the function bindgen as currently written still makes this assumption
717720 self . bindgen (
@@ -728,6 +731,7 @@ impl JsBindgen<'_> {
728731 func,
729732 AbiVariant :: GuestExport ,
730733 & iface_name,
734+ requires_async_porcelain,
731735 ) ;
732736 self . src . push_str ( "\n " ) ;
733737
@@ -861,6 +865,7 @@ impl JsBindgen<'_> {
861865 func : & Function ,
862866 abi : AbiVariant ,
863867 iface_name : & Option < String > ,
868+ requires_async_porcelain : bool ,
864869 ) {
865870 self . src . push_str ( "(" ) ;
866871 let mut params = Vec :: new ( ) ;
@@ -920,7 +925,7 @@ impl JsBindgen<'_> {
920925 . resolve ( self . resolve )
921926 . callee_resource_dynamic ( false )
922927 . asmjs ( false )
923- . requires_async_porcelain ( false )
928+ . requires_async_porcelain ( requires_async_porcelain )
924929 . tracing_enabled ( false )
925930 . maybe_iface_name ( iface_name. as_deref ( ) )
926931 . build ( ) ;
@@ -987,13 +992,23 @@ impl JsBindgen<'_> {
987992 // the function bindgen as currently written still makes this assumption
988993 let sig = self . resolve . wasm_signature ( AbiVariant :: GuestImport , func) ;
989994
995+ // We treat all functions as requiring async porcelain to
996+ // allow for use of `fetch()`
997+ //
998+ // Requiring async porcelain is distinct from a "real"
999+ // P3 async export, in that the callee is *not* expected to follow
1000+ // the async ABI, but instead essentially be treated like an async
1001+ // JS function.
1002+ let requires_async_porcelain = true ;
1003+
9901004 self . bindgen (
9911005 sig. params . len ( ) ,
992- & format ! ( "await { callee}" ) ,
1006+ & callee,
9931007 string_encoding,
9941008 func,
9951009 AbiVariant :: GuestImport ,
9961010 & iface_name,
1011+ requires_async_porcelain,
9971012 ) ;
9981013 self . src . push_str ( "\n " ) ;
9991014
0 commit comments