Stop daemon crashes from terminal-list worker timeouts
getTerminals was the only terminal read that round-tripped the terminal worker process. Under load the IPC call could hit its 10s timeout, and the rejection from a fire-and-forget workspace-update emit propagated as an unhandled rejection — taking down the whole daemon. The daemon already maintains an authoritative mirror of terminal state (every other read is served from it), so getTerminals now reads that mirror locally, preserving the worker's descendant-path aggregation and absolute-path guard. The getTerminals worker IPC request is removed entirely, so no terminal read can stall on the worker anymore. Also adds a defensive .catch to the two fire-and-forget workspace-update sites, and hoists the duplicated assertAbsolutePath guard into one shared helper in path-utils.
This commit is contained in:
@@ -7,8 +7,8 @@ import {
|
||||
} from "./terminal.js";
|
||||
import { captureTerminalLines, type CaptureTerminalLinesResult } from "./terminal-capture.js";
|
||||
import { randomBytes, randomUUID } from "node:crypto";
|
||||
import { resolve, sep, win32, posix } from "node:path";
|
||||
import { isSameOrDescendantPath } from "../server/path-utils.js";
|
||||
import { resolve, sep } from "node:path";
|
||||
import { assertAbsolutePath, isSameOrDescendantPath } from "../server/path-utils.js";
|
||||
import type { TerminalActivity, TerminalActivityState } from "@getpaseo/protocol/terminal-activity";
|
||||
|
||||
export interface TerminalListItem {
|
||||
@@ -97,12 +97,6 @@ export function createTerminalManager(
|
||||
const terminalActivityListeners = new Set<TerminalActivityListener>();
|
||||
const defaultEnvByRootCwd = new Map<string, Record<string, string>>();
|
||||
|
||||
function assertAbsolutePath(cwd: string): void {
|
||||
if (!posix.isAbsolute(cwd) && !win32.isAbsolute(cwd)) {
|
||||
throw new Error("cwd must be absolute path");
|
||||
}
|
||||
}
|
||||
|
||||
function removeSessionById(id: string, options: { kill: boolean }): void {
|
||||
const session = terminalsById.get(id);
|
||||
if (!session) {
|
||||
|
||||
Reference in New Issue
Block a user