🏠 back to Observable

Embind module hangs on load

I’m trying to compile some C++ via emscripten and run it in the browser. I found issues like this which had some helpful ideas, but I feel like I’ve followed a relatively simple pathway and can’t quite figure out what’s going wrong.

I’ve created a notebook which pretty fully describes the issue here:

The fundamental problem is that it works pretty effortlessly in node and in the browser, but I can’t figure out why it seems to load and run but completely hang in Observable.

To clarify, perhaps my problem in addition to getting it to just work is that I’m having a bit of trouble understanding what Observable might be doing or trying to do, or why after trying this all Observable notebooks hang until I quit the browser.

The problem is that the Initialize method returns a then-able: an object that exposes a then method. The then method resolves with itself, so it goes into an infinite loop. In short, it’s like this:

{
  const loop = ({then: resolve => resolve(loop)});
  return Promise.resolve(loop);
}

You can fix this by deleting the then method, or renaming it:

{
  const module = Initialize();
  delete module.then;
  return module;
}

Here’s the relevant issue:

1 Like

Thanks! Wow, that was not the answer I expected. That solves it immediately. Perhaps MODULARIZE is not the option I’m looking for, or perhaps I could kludge around this within the bundle by injecting my own --post-js, but I’m willing to go with it and deal with this awkward thing. :tada: