Wow seems a hot topic:) I was so shocked and forget to google it) btw I solved the problem like this https://github.com/emscripten-core/emscripten/issues/5820#issuecomment-353605456
I think is worth to add it in documentation as workaround. Cause problem still there from 2017. Btw, it was fun to solve this problem without help, so mind blowing. ср, 15 апр. 2020 г. в 23:57, Alon Zakai <[email protected]>: > May be related to https://github.com/emscripten-core/emscripten/pull/10697 > , see discussion and ongoing work there. > > On Wed, Apr 15, 2020 at 1:41 AM Александр Гурьянов <[email protected]> > wrote: > >> 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 >> . >> > -- > 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/CAEX4NpTBDZkiKBB0wVJac6zbOdChyxJfYCWQTfJMsNqYFb21Ag%40mail.gmail.com > <https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpTBDZkiKBB0wVJac6zbOdChyxJfYCWQTfJMsNqYFb21Ag%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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%3DVGQCSQFP3Y6R6YRv81AMQdX%2B%2B5SLU77bBFfDUTp7hrUTA%40mail.gmail.com.
