Debugging Server project
Debugging with vscode
Using a debugger sometimes is much easier than trying to just print things to understand a bug,for the server project we have a configuration that makes it easy for everyone to run in debug mode inside vscode.
In the debug screen you can select "Server" and hit the play button to start the process.
Before running the server there is a task called transpile-server that runs yarn tsc to make sure that thelatest changes in the package/server are being executed.
In a optimal solution we would be doing this transpile-server task in the tasks.json file(inside the tasks.json we can use a type npm for the task that is more ergonomic)
If there are any new environment variables that need to be included before execution, there is a place where they can be added:
Something that we could do to improve the experience is adding a build process to other projects that are used by the server project,but this still can be done with other terminals open.
Modifying the configuration:
To modify the configuration, for now, it is all in the joplin.code-workspace file, but if needed we could also breakthe configuration into two files, one for the launch.json and other for the tasks.json.
References:
Launch option to vscode workspaces
More images:
Running debug commands
When running in development mode, several debug commands can be run by sending requests to /api/debug. These include:
- The
populateDatabasecommand adds content to the database, creating test users with initial data.- Among other things, this allows testing how Joplin Server handles a large number of users, items, and changes. A larger
sizeparameter creates more items.sizecan be either 1, 2, or 3. - Example:
curl --data '{"action": "populateDatabase", "size": 2}' -H 'Content-Type: application/json' http://localhost:22300/api/debug.
- Among other things, this allows testing how Joplin Server handles a large number of users, items, and changes. A larger
- The
benchmarkDeltaPerformancecommand tests the performance ofmodels.change().deltaby callingdeltamultiple times for each user account. Data is saved inpackages/server/delta-perf.csv.ChangeModel.deltais called during sync and has historically been a performance bottleneck.- Example:
curl --data '{"action":"benchmarkDeltaPerformance"}' -H 'Content-Type: application/json' http://localhost:22300/api/debug.