The problem is when you “look” at the form in the IDE, not when you run the app. Forms today are alive even when the app is not running, that is they do run their init code so they can reflect the values of their properties in the form designer.
This was not the case in the past. Forms used to render as black boxes. Custom component were rendered in their default state, regardless of the values of their properties, and only native components were able to reflect the values of some properties.
So, an old app that was working both in the IDE and in production, still works in production, because nothing has changed there, but when you open it in the IDE, you may see messages printed in the console, alerts popping up, or forms showing up as a rectangle with an error message rather than a form with its components.
The correct fix is for you to use the in_designer
as suggested by @stucork to prevent the execution of code that would fail while the app is not running.
I have the same problem when forms make a server call that requires user authentication and fails when the app is not running and the user is not authenticated. For example, if a form needs the values to show in a drop down, I use in_designer
to decide whether to call the server function and get the correct values for the current user or to define dummy values to use in the IDE.
I have the feeling that they will look at the internal error. Internal errors are a way for the app to say “something went wrong, but I don’t know what”, and they should always be managed better by Anvil, not by us, at least with a more useful message.
As a side note, a form that makes 12 server calls at loading time is going to slow down your app to a crawl! If the calls come from the same place, you should consolidate them in one call that returns a dictionary with the 12 values. If they come from 12 different components as suggested by @stucork, you should figure out a way too either preload and cache, or lazy load (and still cache).