You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We often see a problem where models are not created until a tea.WindowSizeMsg is received so it can load in with the correct sizes. However, this creates a common race condition where something tries to set the values of this bubble/model before it has been initialized as another message is received before the WindowSizeMsg, leading to a nil pointer error.
In the meantime having this issue and maybe a disclaimer in the README would be helpful for users trying to debug the issue.
If tea.WindowSizeMsg is really and in all cases the indication that the application had a chance to properly init all models, all other messages could be defered/buffered until the tea.WindowSizeMsg is pushed on the msgs channel.
Basically by waiting on a mutex which gets released once the tea.WindowSizeMsg is pushed into Update()
On the technical side of things, the initial view is called before the first update which means that any view logic around unknown terminal size will need to be accounted for anyway.
More importantly, however, Bubble Tea programs are asynchronous in nature and, as a rule, message order is not guaranteed. If we encourage developers to design their programs in such a manner they'll end up with much more robust applications overall.
If we start to guarantee message order on startup we also risk complicating the mental model. What order do initial messages come in? Do they happen before or after Init()? And so on.
We can reexamine all this again down the road, but for now let's start both with documentation, and patching list.
We often see a problem where models are not created until a
tea.WindowSizeMsg
is received so it can load in with the correct sizes. However, this creates a common race condition where something tries to set the values of this bubble/model before it has been initialized as another message is received before theWindowSizeMsg
, leading to a nil pointer error.In the meantime having this issue and maybe a disclaimer in the README would be helpful for users trying to debug the issue.
Real world example of this issue: orlangure/gocovsh#38
The text was updated successfully, but these errors were encountered: