Repository navigation
Fix wails dev - #1931
Fix wails dev#1931
Conversation
leaanthony
left a comment
There was a problem hiding this comment.
Just a couple of comments. Thoughts?
| log.Error(err.Error()) | ||
| } | ||
| d.LogDebug("Shutdown completed") | ||
| }(d.server, d.logger) |
There was a problem hiding this comment.
I'd be tempted to pass in the address of the waitgroup here
| d.logger.Error(err.Error()) | ||
| } | ||
| d.LogDebug("Shutdown completed") | ||
| }() |
There was a problem hiding this comment.
For consistency, perhaps we should pass everything in, like we do for startup?
There was a problem hiding this comment.
I added the other parameters but I left the d.LogDebug statements the way they are.
I tried to come up with ways to avoid it, but they all felt contrived and/or painful to maintain. Let me know what you think!
There was a problem hiding this comment.
Nice one! I'm now wondering if these have to be 2 goroutines. I'm assuming the server.Start call is blocking otherwise the shutdown process would begin straight away. What do you think about removing the second goroutine and just put everything in the first? Then we could remove the waitgroup altogether?
There was a problem hiding this comment.
Maybe I'm missing something but aren't we now blocking the call to server.Shutdown? sever.Start blocks until someone calls a server.Shutdown, the WaitGroup onto which the server.Shutdown waits for is only decremented when server.Start finishes. So it seems like both are blocking each other.
There was a problem hiding this comment.
I think you're right - I missed the defer in the original whilst looking at github mobile 😬 I take it the dev server can be shut down with out of band actions such as ctrl-c?
There was a problem hiding this comment.
Yeah, since it's running in a separate goroutine, the goroutine and the server will be stopped after the main goroutine exits.
If we don't want to cleanly shutdown, we could just remove the shutdown goroutine.
There was a problem hiding this comment.
@stffabi Great point! I believe you're right. The problem I ran into was that the deferred server.Shutdown() was running immediately because frontend.Frontend.Run() no longer blocks.
It didn't click for me that by the time the waitgroup unblocks, the server has already shut down. And yes, Ctrl-C shuts down the server as expected with the current commit, I've tested it.
It may not make sense to explicitly call server.Shutdown anymore; though I could phase out the waitgroup and make the goroutine wait for a context cancellation instead. I'm not sure what's better, so please let me know your thoughts.
There was a problem hiding this comment.
Personally I'm fine with completely removing the shutdown for the time being. For the devserver an ungraceful shutdown is not much of a problem.
We could revisit this for the server/hybrid mode where a graceful shutdown might be more relevant.
@leaanthony what do you think?
stffabi
left a comment
There was a problem hiding this comment.
LGTM 👍, thanks for this fix 🙏
2ac45bc to
ec07d15
Compare
Fixes #1919
I made the minimum necessary changes to get the dev server working again.
I understand there was a recent refactor in #1909, so please let me know if these changes get in the way of something else.