silverbulletmd / silverbullet

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

Random error kills silverbullet eventually #1154

Open devzero opened 6 days ago

devzero commented 6 days ago

I continually get the crash dump below and as a result it becomes unusable. This is running on NixOS, but my home NixOS machine doesn't have this problem, so it's either related to content of the space, or because this machine is behind a HTTPS proxy with non-standard SSL certs. If I stop the service, wipe out .silverbullet.db* and restart, it fixes it temporarily, but some undetermined amount of time later it happens again every time.

I'm also running the GIT plugin (from SETTINGS):

git:
  autoCommitMinutes: 5
  autoSync: true

I just realized it might be the git plugin, so I just disabled that and will track if that isolates the issue.

Host is a x86_64 NixOS 24.11 system running newest silverbullet from nixpkgs.

Here's the log output:

Using KV as a database backend (/var/lib/silverbullet/.silverbullet.db).
Going to start SilverBullet binding to localhost:3000
Using local disk as a storage backend: /var/lib/silverbullet
Unhandled rejection: PromiseRejectionEvent {
  bubbles: false,
  cancelable: true,
  composed: false,
  currentTarget: Window {},
  defaultPrevented: false,
  eventPhase: 2,
  srcElement: null,
  target: Window {},
  returnValue: true,
  timeStamp: 0,
  type: "unhandledrejection",
  promise: Promise {
    <rejected> ReferenceError: window is not defined
    at IV.hashSHA256 (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:87:33860)
    at IV.init (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:87:33272)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async zX.init (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2384:18073)
    at async rX.start (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2385:7437)
    at async F.gj [as actionHandler] (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2385:13469244)
    at async F.execute (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:24:8601)
    at async F.parseCommand (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:24:6314)
    at async file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2418:6541
  },
  reason: ReferenceError: window is not defined
    at IV.hashSHA256 (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:87:33860)
    at IV.init (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:87:33272)
    at eventLoopTick (ext:core/01_core.js:175:7)
    at async zX.init (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2384:18073)
    at async rX.start (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2385:7437)
    at async F.gj [as actionHandler] (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2385:13469244)
    at async F.execute (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:24:8601)
    at async F.parseCommand (file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:24:6314)
    at async file:///nix/store/d3pvmgayhavxnq5210z14p8h1nzjfqgk-silverbullet-0.9.4/lib/silverbullet.js:2418:6541
zefhemel commented 5 days ago

This is an error I've seen when running SB with deno 2. Are you doing that? If so, you may want to switch to an edge build which has been updated for Deno 2.

devzero commented 5 days ago

NixOS is, in fact, running deno 2.0.5. Though I noticed, that as soon as I removed the git plugin config from my SETTINGS, it stopped crashing. I've patched my nix config to use edge (overlay is below for those who care), though I'll have to update the hash every time edge.silverbullet.md changes. I didn't notice any changes in the changelog talking about post 0.9.4 feature work, but I guess it's just in progress.

{channels, inputs, ...}:
  final: prev: {
    silverbullet = prev.silverbullet.overrideAttrs (attrs: {
      version = "0.9.5";
      src = final.fetchurl {
        url = "https://edge.silverbullet.md/silverbullet.js";
        hash = "sha256-1W9gR2smsRhipEd3kfonkTpkbDdbKXzZZ2DFZynNsgM=";
      };
    });
  }
devzero commented 5 days ago

And that builds, but fails to run:

Nov 14 15:30:26  silverbullet[777850]: Download https://deno.land/std@0.221.0/text/closest_string.ts
Nov 14 15:30:26  silverbullet[777850]: Download https://deno.land/std@0.221.0/fmt/colors.ts
Nov 14 15:30:26  silverbullet[777850]: Download https://deno.land/std@0.221.0/console/unicode_width.ts
Nov 14 15:30:26  silverbullet[777850]: Download https://deno.land/std@0.221.0/encoding/base64url.ts
Nov 14 15:30:26  silverbullet[777850]: Download https://deno.land/std@0.170.0/streams/readable_stream_from_iterable.ts
Nov 14 15:30:26  silverbullet[777850]: Download https://deno.land/std@0.170.0/io/buffer.ts
Nov 14 15:30:27  silverbullet[777850]: error: Operation not permitted (os error 1) (for '/var/empty/.cache/deno/remote/https/deno.land')
Nov 14 15:30:27  silverbullet[777850]: Check the permission of the directory.
Nov 14 15:30:27  silverbullet[777850]:     at file:///nix/store/555klhxs0arc90pjqpmbjhncb39lvf86-silverbullet-0.9.5/lib/silverbullet.js:2:125
Nov 14 15:30:27  systemd[1]: silverbullet.service: Main process exited, code=exited, status=1/FAILURE
zefhemel commented 5 days ago

If you update plugs now this should be fixed. Just pushed a new git plug build.