Hi all - is there a way to make the front-end / react hot reload during plugin development? Using the elastic & Kibans Dev environment hot reload only appears to work when the API portions of the project are modified, but not on the front end / react side. I'm using the standard 'yarn start' method for bringing Kibana up. This is true on both 7.5.0 and 7.6.0.
Also, is there a way to view better debugging? Sometimes when there are syntax errors in the react side, the console throws out of memory errors when truly the underlying issue is a syntactic issue - this makes debugging reaaaaly hard.
About the first part: By hot-reloading do you mean reloading the browser tab automatically when something changes? The dev server is detecting if frontend code changes and runs the compile step again, you just have to refresh your browser tab and it will run the changed code.
I can confirm what @tiburon_security said about hot realod.
Trying to apply some changes (simply modyfing a text of an EuiButton), reloading the browser I don't see reflect any changes.
Run my kibana istance using "yarn start" command.
When I reload the browser in fact, I don't see any new optimizations server side
Yeah hot reload / on the fly compilation in response to a code change is what I'm referring too. In 7.6.0 and 7.5.0 this doesn't seem to work. When I make a code change and refresh the browser, the code is not recompiled automatically to reflect those changes. When I make a change on the API side, the console running Kibana indicates that it detected a code change and begins the recompilation automatically - this does not happen when the change is made on the front-end side. This makes developing Kibana plugins a really terrible experience.
RE: weird errors, it looks like upping the RAM helped. Before, I was getting the memory errors even for REALLY simple syntactical issues (like console,log instead of console.log).
I'm running this on Ubuntu Server 18.04 x64 via VirtualBox w/ 12GB RAM and 4vCPU's allocated. On a fresh instance I built the dev environment as follows:
In my scenario, I have Kibana installed at the system root (i.e. /kibana).
I'm not entirely sure what you meant by 'does it happen on master?' but I assume you're asking whether it happens if I modify Kibana core UI code - quick answer is yes, it still doesn't hot reload. For this test, I navigated to the top level dir (/kibana) and fired up elasticsearch (yarn es snapshot), then I started kibana (yarn start) & the server comes up.
server log [20:46:21.468] [info][server][Kibana][http] http server running at http://localhost:5603/iyk
optmzr log [20:47:00.353] [info][optimize:dynamic_dll_plugin] No need to compile client vendors dll
optmzr log [20:47:00.354] [info][optimize:dynamic_dll_plugin] Finished all dynamic dll plugin tasks
optmzr log [20:47:00.357] [info][optimize] Optimization success in 60.68 seconds
I then modified the text on the homepage (/kibana/src/legacy/core_plugins/kibana/public/home/np_ready/components/home.js) from 'Manage and Administer the Elastic Stack' to 'Hi', saved the file on the server. There was no immediate change in the console (i.e. Kibana didn't inidicate that it observered a change and was recompiling). Refreshing the browser also did not trigger the recompliation, nor cause the text to change. Manually stopping the kibana server (ctrl+c in the console running it) and restarting (yarn start) obviously recompiles the code and the changes are visible via the browser.
This exact scenario is what happens when I modify plugins (for example in plugins/myplugin/public/components/main/main.js). I have to manually stop the kibana server and start it in order for changes to be reflected, which is obviously incredibly tedious and time consuming.
In contrast, when I edit in the API side, auto recompilation occurs:
restarting server due to changes in "plugins/srirachaiq_alerts/server/routes/example.js"
To avoid this kind of problem, I created a React application (using create-react-app generator) and I installed in It @elastic/eui and other useful dependencies.
In this way, once I finisched at least the front-end, I can include the code inside the kibana plugin
At the moment I think It is the best to speed up the development...
Sound workaround that I've also been considering... the only reason I've avoided doing this is because my plugin is leveraging various API's so I'd need to temporarily rewrite all the URL's in the dev environment. Not the worst thing in the world, but it'd be real nice if I could do all the work in the Kibana dev envrionment.
Wow.....actually I've up an express instance. At this point getting your tip...so I could use the kibana plugin (only the server side) to manage routes...
Thx!.
I hope anyway this problem will be fixed in future...
Hey Nicolap, I think I might have accidentally found a fix. When I was going down the rabbit hole of just doing the dev work in a seperate create-react-app instance, I got an error upon yarn starting my new app: "error enospc system limit for number of file watchers reached." In fixing this, I followed this stackoverflow snippet:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
After this I tried updating some text in my Kibana plugin out of curiosity and it immediately reloaded in the console:
optmzr log [20:44:38.926] [info][optimize:dynamic_dll_plugin] No need to compile client vendors dll
optmzr log [20:44:38.927] [info][optimize:dynamic_dll_plugin] Finished all dynamic dll plugin tasks
optmzr log [20:44:38.927] [info][optimize] Optimization success in 5.65 seconds
let me know if this works for you? If so we might be able to get it added to the dev guide for Kibana.
@Nicolap I'm glad it worked - you helped me accidentally stumble upon the fix! If you have more RAM available on your box follow flash's recommendation to up the RAM kibana uses, seems to have gotten my optimization time down.
@flash1293 how do we get a comment about upping inotify added to the dev documentation?
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.