Hot reload while plugin development not working

Hi @phdehner we don’t support “hot reload” in plugins in Grafana. only regular full page reload, but it does seem that is what you are doing.

I tested a setup like you described but with linux arch as the host machine:

  • new panel plugin generated from create plugin
  • run npm install
  • run npm run dev
  • run npm run server[1]
  • open http://localhost:3000 in my browser

It all worked as expected. When I did a change in my SimplePanel.tsx I saw the page fully reload (no hot reload) and the changes appeared in my dashboard.

A few things to try and question for you:

  • Make sure you let npm run dev run and finish the first compile before you start the server.
  • Make sure you are opening the correct local instance localhost:3000
  • Make sure you don’t have any other local grafana instance running (maybe from other plugin?)
  • Make sure you are editing the plugin files from the same folder where you ran dev and serve. You can’t, for instance, run server in plugin-a, edit files of plugin-b and expect to see the changes.
  • When you edit a file in your plugin, observe the console where you run dev and see if it generates more output. Usually on every file change you see an update of webpack compiling such as assets by status... (and so on).

For the sake of discard, maybe you can do the whole process again with a new plugin and make sure you are running all the commands only in the newly created plugin and make sure you stop all other server(s) you ran before.

I know many of the recommendations here look too basic but oh so many times I felt victim of not being in the correct directory or opening the wrong file that it is now the first thing I check.

Finally you are using nodejs 20. Grafana create-plugin supports the current LTS (at the moment of writing that is nodejs 18). I tested it all the previous with nodejs 20 and it worked fine but maybe try to use 18 and see if maybe that’s the problem.

Let me know if this helps fix the issue.

[1] It is important you only run server after you let dev run and do the first compile.

2 Likes