ihp
ihp copied to clipboard
IHP requires restart after generating new Controller
Hi, its me again trying to push forward a model containing floats ;-)!
Steps to reproduce
- ihp-new test
- cd test and ./start
- create new table in schema designer
- update and push to db
- create new codegen/Controller for that table
Expected
Successful compilation similar to the example with "Posts"
Bug
received Compilation error due to missing references, which is resolved by restarting IHP
Web/Controller/ProjectProducts.hs:6:1
Could not find module ‘Web.View.ProjectProducts.Edit’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
6 | import Web.View.ProjectProducts.Edit
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This might be some kind of race condition :) I cannot reproduce the issue, but I believe that this indeed can occur.
I think this is caused by the generators plan order in executePlan
.
The code generation plan for a controller looks like:
[ CreateFile { filePath = applicationName <> "/Controller/" <> controllerName <> ".hs", fileContent = (generateController schema config) }
, AppendToFile { filePath = applicationName <> "/Routes.hs", fileContent = (controllerInstance config) }
, AppendToFile { filePath = applicationName <> "/Types.hs", fileContent = (generateControllerData config) }
, AppendToMarker { marker = "-- Controller Imports", filePath = applicationName <> "/FrontController.hs", fileContent = ("import " <> applicationName <> ".Controller." <> controllerName) }
, AppendToMarker { marker = "-- Generator Marker", filePath = applicationName <> "/FrontController.hs", fileContent = (" , parseRoute @" <> controllerName <> "Controller") }
]
<> viewPlans
When executePlan
did the first step (which creates the Controller file), a reload might already be triggered. But at that point the views are not generated yet. The views will be generated at the end once everything else is done.
So basically what IHP is doing:
Create Web/Controller/ProjectProducts.hs with all the view imports already
Reload Dev Server
Create View File Web/View/ProjectProducts/New.hs
Create View File Web/View/ProjectProducts/....hs
A better plan fixing this issue would look like:
Create View File Web/View/ProjectProducts/New.hs
Reload Dev Server
Create View File Web/View/ProjectProducts/....hs
Reload Dev Server
Create Web/Controller/ProjectProducts.hs with all the view imports already
Reload Dev Server
@mpscholten This seems to still exist as an issue, I have this happening on a brand new project. It also seems that when this occurs, the steps are not fully executed, for example: FrontController.hs
was not updated among other files. For reference, I used the dashboard codegen to generate things and it completed "successfully".
@jamesrweb when the files are not fully updated, this seems like a new kind of issue. Was there any error before that in the console output?
@jamesrweb when the files are not fully updated, this seems like a new kind of issue. Was there any error before that in the console output?
No, nothing at all except the same message @themmes saw to use -v
.
The dashboard said everything was successful as I mentioned, only compile / runtime caught the issue as I said.
I ended up having to manually do the generator steps in the end.