Space-script is not loaded

Hi,

I am using zefhemel/silverbullet latest 64f68b5300ea and the space-scripts is not loaded.

I tried to put them everywhere, but it wont work. I also tried different web browsers.

silverbullet.registerFunction("addThree", (a) => {
  return a + 3;
});
{{addThree(2)}}

I don’t disabled them.

space on  master
🦄 rg SB_SPACE_SCRIPT

space on  master
🙊

Thanks!

When you reload, is there anything in the logs? The logs you show is when the function is trying to be used, not when reloading SilverBullet.

It’s possible some other SpaceScript fails to load and prevent this one from loading properly, this one seems to work fine for me.

The server logs are going to be more helpful. Template rendering happens on the server (unless you use sync mode, which is another thing to try) so the browser you use shouldn’t make any difference.

To reproduce,

I created a file in silverbullet/space/Scripts/foo.md With this content:

Then I put this code in Self.md

{{addThree(2)}}

Now I restart the docker image and watch the log.

After visiting Self.md I get:

silverbullet-silverbullet-1  | Booted server with hostname 0.0.0.0
silverbullet-silverbullet-1  | Listening on http://0.0.0.0:3000/
silverbullet-silverbullet-1  | SilverBullet is now running: http://localhost:3000
silverbullet-silverbullet-1  | Requested file index.md
silverbullet-silverbullet-1  | Requested file index.md
silverbullet-silverbullet-1  | Requested file Hubs/Self.md
silverbullet-silverbullet-1  | Requested file SETTINGS.md
silverbullet-silverbullet-1  | Booting up worker for template
silverbullet-silverbullet-1  | Requested file Library/Core/Widget/Table of Contents.md
silverbullet-silverbullet-1  | Requested file Library/Core/Widget/Linked Mentions.md
silverbullet-silverbullet-1  | Error rendering template Error: Unknown function: addThree
silverbullet-silverbullet-1  |     at data:application/javascript;base64,dmFyIFVlPU9iamVjdC5k......dHtJbyBhcyBwbHVnfTsK:1:940
silverbullet-silverbullet-1  |     at data:application/javascript;base64,dmFyIFVlPU9iamVjdC5k......dHtJbyBhcyBwbHVnfTsK:1:988
silverbullet-silverbullet-1  |     at innerInvokeEventListeners (ext:deno_web/02_event.js:754:7)
silverbullet-silverbullet-1  |     at invokeEventListeners (ext:deno_web/02_event.js:801:5)
silverbullet-silverbullet-1  |     at dispatch (ext:deno_web/02_event.js:658:9)
silverbullet-silverbullet-1  |     at dispatchEvent (ext:deno_web/02_event.js:1043:12)
silverbullet-silverbullet-1  |     at pollForMessages (ext:runtime_main/js/99_main.js:311:7)
silverbullet-silverbullet-1  |     at eventLoopTick (ext:core/01_core.js:174:7)
silverbullet-silverbullet-1  | An exception was thrown as a result of invoking function renderTemplate error: Unknown function: addThree
silverbullet-silverbullet-1  | Booting up worker for query
silverbullet-silverbullet-1  | Requested file Library/Core/Widget/Linked Tasks.md
silverbullet-silverbullet-1  | Requested file Hubs/Self.md

Tried more code. This is the result

silverbullet-silverbullet-1  | Requested file Library/Core/Widget/Linked Tasks.md
silverbullet-silverbullet-1  | Error rendering template Error: Unknown function: helloYeller
silverbullet-silverbullet-1  |     at data:application/javascript;base64,dmFyIFVlPU9iamVjdC5k......dHtJbyBhcyBwbHVnfTsK:1:940
silverbullet-silverbullet-1  |     at data:application/javascript;base64,dmFyIFVlPU9iamVjdC5k......dHtJbyBhcyBwbHVnfTsK:1:988
silverbullet-silverbullet-1  |     at innerInvokeEventListeners (ext:deno_web/02_event.js:754:7)
silverbullet-silverbullet-1  |     at invokeEventListeners (ext:deno_web/02_event.js:801:5)
silverbullet-silverbullet-1  |     at dispatch (ext:deno_web/02_event.js:658:9)
silverbullet-silverbullet-1  |     at dispatchEvent (ext:deno_web/02_event.js:1043:12)
silverbullet-silverbullet-1  |     at pollForMessages (ext:runtime_main/js/99_main.js:311:7)
silverbullet-silverbullet-1  |     at eventLoopTick (ext:core/01_core.js:174:7)
silverbullet-silverbullet-1  | An exception was thrown as a result of invoking function renderTemplate error: Unknown function: helloYeller
silverbullet-silverbullet-1  | Requested file _plug/query.plug.js
silverbullet-silverbullet-1  | Writing file Dailies/2024-11-09.md
silverbullet-silverbullet-1  | Requested file SETTINGS.md

I’m not sure why, but client mode has resolved many of my issues with SilverBullet.

Now it works in client mode. Initially, it didn’t – I had to switch to another page and then back again to get it to work.

This issue was also fixed using client mode: Some of my pages are not indexed - #2 by azzamsa