silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

Silverbullet sync: error General sync error: Unexpected token '<'...

Open elliottw opened this issue 1 year ago • 3 comments

I'm trying to use the sync feature for two instances, one locally (macos sb version 0.9.2) and one on deno.dev following the instructions in the community guide.

From my local machine, I try: silverbullet % SB_AUTH_TOKEN=supersecret silverbullet sync . https://elliottio.deno.dev/

Which returns this error:

Going to synchronize . and https://elliottio.deno.dev/
Using local disk as a storage backend: /Users/elliott/silverbullet
[sync] Performing a full sync cycle...
Fetched uncached file list in 5.343916000000007 ms
error General sync error: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
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> SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at parse (<anonymous>)
    at packageData (ext:deno_fetch/22_body.js:381:14)
    at consumeBody (ext:deno_fetch/22_body.js:247:12)
    at eventLoopTick (ext:core/01_core.js:168:7)
    at async lR.syncFiles (https://get.silverbullet.md/:2418:1849)
    at async F.No [as actionHandler] (https://get.silverbullet.md/:2418:6244)
    at async F.execute (https://get.silverbullet.md/:24:8601)
    at async F.parseCommand (https://get.silverbullet.md/:24:6314)
    at async https://get.silverbullet.md/:2418:6541
  },
  reason: SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at parse (<anonymous>)
    at packageData (ext:deno_fetch/22_body.js:381:14)
    at consumeBody (ext:deno_fetch/22_body.js:247:12)
    at eventLoopTick (ext:core/01_core.js:168:7)
    at async lR.syncFiles (https://get.silverbullet.md/:2418:1849)
    at async F.No [as actionHandler] (https://get.silverbullet.md/:2418:6244)
    at async F.execute (https://get.silverbullet.md/:24:8601)
    at async F.parseCommand (https://get.silverbullet.md/:24:6314)
    at async https://get.silverbullet.md/:2418:6541
}

Using --snapshot snapshot.json gives the same result.

A slight tangent: I'd love to have these two instances continuously synced. The major reason for this is locally editing attached files. Is there any way to do this instead of manually performing sync?

elliottw avatar Sep 03 '24 12:09 elliottw

The sync command is a little experimental. I was contemplating removing it actually. What is your use case? Because I would assume/hope you can just rely on Sync mode (built in to the PWA) for offline access.

zefhemel avatar Sep 03 '24 17:09 zefhemel

I'd like to have the markdown files accessible locally on a laptop that isn't always on so I can edit attached pdfs and use other editors for the markdown files, while also accessing my notes from my phone when not at home. I guess I could run a vps and syncthing but i've read about issues with the db file getting corrupt when trying to simply sync files across devices.

elliottw avatar Sep 03 '24 20:09 elliottw

Ok, yeah for that using sync can make sense indeed. Syncthing should also work, but you may want to exclude the .silverbullet.db file from being synced. Not sure how syncthing deals with concurrent edits.

zefhemel avatar Sep 04 '24 17:09 zefhemel