Skip to content

Fix wails dev - #1931

Merged
leaanthony merged 3 commits into
wailsapp:masterfrom
JulioDRF:bugfix/1919-broken-dev
Oct 4, 2022
Merged

leaanthony merged 3 commits into
wailsapp:masterfrom
JulioDRF:bugfix/1919-broken-dev

Conversation

@JulioDRF

@JulioDRF JulioDRF commented Oct 2, 2022

Copy link
Copy Markdown
Contributor

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.

@leaanthony leaanthony left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of comments. Thoughts?

log.Error(err.Error())
}
d.LogDebug("Shutdown completed")
}(d.server, d.logger)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to pass in the address of the waitgroup here

d.logger.Error(err.Error())
}
d.LogDebug("Shutdown completed")
}()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, perhaps we should pass everything in, like we do for startup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

@JulioDRF JulioDRF Oct 3, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah happy with that.

@stffabi stffabi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍, thanks for this fix 🙏

@stffabi
stffabi force-pushed the bugfix/1919-broken-dev branch from 2ac45bc to ec07d15 Compare October 4, 2022 18:49
@stffabi
stffabi enabled auto-merge (squash) October 4, 2022 18:50
@leaanthony
leaanthony merged commit bd378b2 into wailsapp:master Oct 4, 2022
@JulioDRF
JulioDRF deleted the bugfix/1919-broken-dev branch October 4, 2022 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v2 linux] wails dev command fails on latest

3 participants