silverbulletmd / silverbullet

The knowledge tinkerer's notebook
https://silverbullet.md
MIT License
2.45k stars 177 forks source link

Faulty plugs brick silverbullet #990

Open MrMugame opened 2 months ago

MrMugame commented 2 months ago

If a plug is faulty and never returns a manifest it can brick the silverbullet instance, because this promise never resolves, resulting in the silverbullet instance to never finish initializing. _lib/plugos/sandboxes/workersandbox.ts

return new Promise((resolve) => {
  this.worker!.onmessage = (ev) => {
    if (ev.data.type === "manifest") {
      this.manifest = ev.data.manifest;
      // Set manifest in the plug
      this.plug.manifest = this.manifest;

      // Set assets in the plug
      this.plug.assets = new AssetBundle(
        this.manifest?.assets ? this.manifest.assets as AssetJson : {},
      );

      return resolve();
    }

    this.onMessage(ev.data);
  };
});
zefhemel commented 2 months ago

Right, I suppose the best way to handle this is to add a load timeout.