Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Fix ineffective restartInitiated guard with proper debouncing

Andras Bacsai2fc870c6eb08
diff --git a/app/Livewire/Server/Navbar.php b/app/Livewire/Server/Navbar.php
index 6da1edd776..cd9cfcba64 100644
--- a/app/Livewire/Server/Navbar.php
+++ b/app/Livewire/Server/Navbar.php
@@ -67,7 +67,7 @@ class Navbar extends Component
try {
$this->authorize('manageProxy', $this->server);
- // Prevent duplicate restart messages (e.g., from double-click or re-render)
+ // Prevent duplicate restart calls
if ($this->restartInitiated) {
return;
}
@@ -75,10 +75,6 @@ class Navbar extends Component
// Always use background job for all servers
RestartProxyJob::dispatch($this->server);
- // $this->dispatch('info', 'Proxy restart initiated.');
-
- // Reset the flag after a short delay to allow future restarts
- $this->restartInitiated = false;
} catch (\Throwable $e) {
$this->restartInitiated = false;
@@ -147,6 +143,11 @@ class Navbar extends Component
$this->dispatch('activityMonitor', $event['activityId']);
}
+ // Reset restart flag when proxy reaches a stable state
+ if (in_array($this->proxyStatus, ['running', 'exited', 'error'])) {
+ $this->restartInitiated = false;
+ }
+
// Skip notification if we already notified about this status (prevents duplicates)
if ($this->lastNotifiedStatus === $this->proxyStatus) {
return;
diff --git a/resources/views/livewire/server/navbar.blade.php b/resources/views/livewire/server/navbar.blade.php
index b0802ed1e6..4f43ef7e20 100644
--- a/resources/views/livewire/server/navbar.blade.php
+++ b/resources/views/livewire/server/navbar.blade.php
@@ -181,6 +181,7 @@
}
});
$wire.$on('restartEvent', () => {
+ if ($wire.restartInitiated) return;
window.dispatchEvent(new CustomEvent('startproxy'))
$wire.$call('restart');
});