silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

Faulty plugs brick silverbullet

Open MrMugame opened this issue 1 year ago • 1 comments

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/worker_sandbox.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);
  };
});

MrMugame avatar Jul 28 '24 14:07 MrMugame

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

zefhemel avatar Jul 28 '24 18:07 zefhemel