Skip to content

Commit

Permalink
fix: Handle WebSocket connection close in terminal.blade.php
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Sep 17, 2024
1 parent ea877f3 commit d92819a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions resources/views/livewire/project/shared/terminal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ function initializeWebSocket() {
socket.onerror = (e) => {
console.error('WebSocket error:', e);
};
socket.onclose = () => {
console.log('WebSocket connection closed');
setInterval(() => {
$wire.dispatch('error', 'Connection to terminal lost, please refresh the page.');
}, 2000);
};
}
}
Expand Down Expand Up @@ -209,8 +215,8 @@ function checkIfProcessIsRunningAndKillIt() {
term.resize(termWidth, termHeight);
socket.send(JSON.stringify({
resize: {
cols: termWidth,
rows: termHeight
cols: 600,
rows: 600
}
}));
}
Expand Down

0 comments on commit d92819a

Please sign in to comment.