Hi, I started with some query plug implementations, but I’m having real difficulties finding out why my plugs return only empty data.
When I’m writing a command everything is going smooth, I can see the service workers in the Sources tab in my browser, set breakpoints there and see the output of console.log.
However, when I try to write a method that reacts to events: ["query:something"] the execution seems to happen in the backend, I can’t set breakpoints in the compiled _plug/something.plug.js and console.log output doesn’t appear anywhere.
Can someone give me some tips on how to debug / find out what is happening inside my plug code in that case?
Hi, have you tried running the silverbullet server from source? Even if I’m developing a plug I tend to do that, so I have a chance to look at the main application code, and not mess up my regular notes.
Recently I was doing something about indexing (which happens on backend) and I did get my console.log output in the terminal in which I ran deno task watch-server ./test_space from README in main repo
I’m running the server through a debugging session in VS Code. I can see an RPC for the query plugin being made and follow that up to some point in a Deno library in 11_worker.js where it gets too asynchronous for me to understand what’s happening
I can see the ordinary server logs in the console, but nothing I console.log or console.error from my plug…
Have you considered using the editor.flashNotification syscall? I know it’s much less convenient than console.log, but maybe it’ll help you figure out the normal logging?
I think somehow query functions are executed differently than others. I didn’t have any issues with command functions.
In query functions you also can’t use editor.flashNotification, it throws an exception.
We probably need @zef for clarification and best practices
Template and query rendering is indeed delegated to the server, except when you run in Sync mode. So if you want to run a debugger, that may be the way to do that. Honestly, I don’t use debuggers myself (yikes), I’m more of a console.log debuggers.
On that topic, console.log should work perfectly fine also for this purpose, except of course that since queries and templates are executed on the server, console.logs will also appear on the server log (standard output) instead of in the browser. So perhaps you were looking in the wrong place?