I’m not sure this is even possible. At a minimum I imagine you would need to call it from something async-y on the C# side, but someone with more recent C# chops can chime in.
My understanding is the only way to call from outside Unity back into Unity is with the UnitySendMessage() API.
I have had issues with the keyword async when using jslib. There is some workarounds out there. The most dynamic solution I have found is either use JS injection using new Function(async_here), or you could write your async code in a separate JS file and run it from the jslib call. Both involve using SendMessage to communicate to Unity.
I don’t know if this has also something to do with es6 support.
It looks like the emscripten version that unity uses to process the jslib files, doesnt understand es6 syntax.
For example Arrow functions also dont work
If you want async inside your jslib you can either create the function at runtime from string using new Function(), This allows all ES6 functionality, though may have some security concerns. Otherwise you can use .then() syntax directly in jslib. No awaits, No arrow functions, no “let” because of emscripten ES6 not supported.
If you wan’t async callbacks to C# the best implementation is custom built using the SendMessage as suggested above. General flow would be: Call a jslib function that does some async task, implement a C# wait for variable to change, when the async sends the message to C# it sets the variable, your wait ends and you can continue.