Add error handling to terminal creation

Wrap terminal creation in try-catch to prevent session creation
from failing if the terminal emulator fails to initialize. The
session will still work, just without ANSI processing.
This commit is contained in:
Jared Miller 2026-01-31 12:01:07 -05:00
parent 58996a51f8
commit 6342c7a699
Signed by: shmup
GPG key ID: 22B5C6D66A38B06C

View file

@ -460,8 +460,16 @@ const server = Bun.serve<SessionData>({
// Create terminal emulator wide enough to avoid premature wrapping
// Browser CSS handles responsive display; we just need ANSI processing
const termSession = createTerminal(300, 50);
sessionTerminals.set(session.id, termSession);
try {
const termSession = createTerminal(300, 50);
sessionTerminals.set(session.id, termSession);
} catch (error) {
console.error(
`Failed to create terminal for session ${session.id}:`,
error,
);
// Session will work but output won't be processed through terminal emulator
}
console.debug(
`Session ${session.id} started for device ${device.id}`,