xbrowsersync / api

Server-side REST API that serves requests from xBrowserSync client apps
GNU General Public License v3.0
783 stars 81 forks source link

Can't make any sync IDs #67

Closed finnblue8 closed 2 years ago

finnblue8 commented 3 years ago

Hey there -- love this project, been using it with the official service since May this year and decided to host my own.

I'm using the manual installation method instead of the Docker image because I have another application on the same machine running on port 443 already, and I haven't figured out a way to modify the ports Caddy uses for reverse proxy. I already have SSL certificates for the application already on 443, so it's honestly more convenient for me to run XBS manually.

I've followed the instructions to the letter -- running Node.js 16.10, MongoDB from the official repository (5.0.3), XBS API version 1.1.13. OS is Ubuntu LTS 20.04.3.

All the networking works fine. XBS runs exclusively over HTTPS and is exposed to the Internet through an open port 8080. However I can't use my XBS service because whenever I attempt to make a new sync ID (brand new service, there are none currently), I'll type in an encryption password in the app, the API will give me the following error, and the app will subsequently tell me "Connection to service lost":

{"name":"xBrowserSync_api","hostname":"*my hostname","pid":7114,"level":50,"req":{"method":"POST","url":"/bookmarks","headers":{"host":"*my domain*:8080","user-agent":"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0","accept":"application/json, text/plain, */*","accept-language":"en-US,en;q=0.5","accept-encoding":"gzip, deflate, br","content-type":"application/json;charset=utf-8","accept-version":"1.1.3","content-length":"19","dnt":"1","connection":"keep-alive","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin"},"remoteAddress":"::ffff:*my IP address*","remotePort":1127},"err":{"message":"Bookmark validation failed: _id: Supplied argument has incorrect type","name":"ValidationError","stack":"ValidationError: Bookmark validation failed: _id: Supplied argument has incorrect type\n at model.Document.invalidate (/home/robert/xBrowserSync/api/node_modules/mongoose/lib/document.js:2782:32)\n at $__applyDefaults (/home/robert/xBrowserSync/api/node_modules/mongoose/lib/document.js:462:17)\n at model.Document (/home/robert/xBrowserSync/api/node_modules/mongoose/lib/document.js:166:5)\n at model.Model (/home/robert/xBrowserSync/api/node_modules/mongoose/lib/model.js:106:12)\n at new model (/home/robert/xBrowserSync/api/node_modules/mongoose/lib/model.js:4911:15)\n at BookmarksService.createBookmarks_v2 (/home/robert/xBrowserSync/api/dist/services/bookmarks.service.js:93:36)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async BookmarksRouter.createBookmarks_v2 (/home/robert/xBrowserSync/api/dist/routers/bookmarks.router.js:79:29)"},"msg":"Exception occurred in BookmarksService.createBookmarks","time":"2021-10-02T00:39:43.614Z","v":0}

This happens every time I try to make a new sync ID no matter what I do.

Stuff I've tried:

  1. I thought it might be because I was using a 128-character random password with symbols that might be illegal in MongoDB. The same error gets generated with even the simplest of passwords like all lowercase, and character length does not seem to matter.
  2. Reinstalled both Node.js and MongoDB multiple times to no avail. Wiped and recreated the XBS database according to the readme like three times to no avail.
  3. Checked all permissions -- both my user and the user I'm running the API with (root) have full permissions to every directory in the API's folder. MongoDB has full permissions to everything in its directories.
  4. Checked that the API is successfully connecting to the database -- it is because if it doesn't then the API refuses to start.

Based on what the logs are saying I feel like this might not be an XBS issue, but rather an issue with Mongoose. Clearly something is wrong on the Mongoose side of things.

Any help would be greatly appreciated! I would love to use my own service, and I haven't found anything on the Internet both here or anywhere else referring to this particular issue.

finnblue8 commented 2 years ago

Closing this issue -- after scrapping my whole Node.js/Mongo/XBS setup from when this was posted and starting from scratch the issue has resolved itself. I have no idea what it was nor what I did different that fixed it. The only thing I changed was that I used Node.js LTS 16.13.0 instead of 16.10.