Hi. I using `-s MODULARIZE=1` for my module, inside modern async/await
environment. I think that design of Module.then is not good. As said
Module.then is promise like function, but it returns it self at the
end. So this promise will never ends in await case. I spent a lot of
time to find why all browsers hangs with my code.
Problem can be described as follow:
```
const Module = {}; // const Module = MyCode();
Module.then = function(cb) { // declared in postamble.js
cb(Module);
return Module; // problem place
};
// How I want to use it
const module = await new Promise((resolve) =>
Module.then(resolve));
// here we have intialized module
```
If you paste this code in browser it will hang, because await is never
finished. Module.then will return promise-like object forever, so
browser will call `then` forever.
My suggestion is to remove `return Module` at the end of `then`, or
rename `then` method to avoid name clashing with Promise. At least we
need to change documentation, and notice that problem exists.
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVF8pmdYAdMQD5XpdyOmW%2B7-xZHtbpk7SyzG2uXm3fv0QQ%40mail.gmail.com.