Skip to content

Commit e26c92f

Browse files
committed
Catch errors on resizing
1 parent 8997b33 commit e26c92f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ async function createTerminal(element: HTMLElement, toDispose: DisposableCollect
142142
toDispose.push(term);
143143

144144
window.term = term; // Expose `term` to window for debugging purposes
145-
term.onResize((size) => {
146-
resizeRemoteTerminal(size, pid);
145+
term.onResize(async (size) => {
146+
await resizeRemoteTerminal(size, pid);
147147
});
148148
protocol = location.protocol === "https:" ? "wss://" : "ws://";
149149
socketURL = `${protocol + location.hostname + (location.port ? ":" + location.port : "")

src/lib/remote.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@ import { IXtermWindow } from "./types";
33

44
declare let window: IXtermWindow;
55

6-
export const resizeRemoteTerminal = (size: { cols: number; rows: number }, pid: number) => {
6+
export const resizeRemoteTerminal = async (size: { cols: number; rows: number }, pid: number) => {
77
if (!pid) {
88
return;
99
}
1010
const cols = size.cols;
1111
const rows = size.rows;
1212
const url = `/terminals/${pid}/size?cols=${cols}&rows=${rows}`;
1313

14-
fetch(url, { method: "POST" });
14+
try {
15+
await fetch(url, { method: "POST" });
16+
} catch (e) {
17+
console.error(`Failed to resize the remote shell: ${e}`);
18+
}
1519
}
1620

1721
export const initiateRemoteCommunicationChannelSocket = async (protocol: string) => {

0 commit comments

Comments
 (0)