Kevin Lubick | 275eaff | 2019-01-04 14:38:29 -0500 | [diff] [blame] | 1 | // See https://github.com/kripken/emscripten/issues/5820#issuecomment-385722568 |
| 2 | // for context on why the .then() that comes with Module breaks things (e.g. infinite loops) |
| 3 | // and why the below fixes it. |
| 4 | Module['ready'] = function() { |
| 5 | return new Promise(function (resolve, reject) { |
| 6 | delete Module['then']; |
| 7 | Module['onAbort'] = reject; |
Kevin Lubick | faa7387 | 2019-01-06 22:27:54 -0500 | [diff] [blame] | 8 | if (runtimeInitialized) { |
| 9 | resolve(Module); |
| 10 | } else { |
| 11 | addOnPostRun(function() { |
| 12 | resolve(Module); |
| 13 | }); |
| 14 | } |
Kevin Lubick | 275eaff | 2019-01-04 14:38:29 -0500 | [diff] [blame] | 15 | }); |
| 16 | } |
| 17 | // TODO(kjlubick): Shut .then() entirely off in 0.6.0 by uncommenting below. |
| 18 | // delete Module['then']; |