louislam/dockge · error · Error

Terminal not found or it is not a Interactive Terminal.

Error message

Terminal not found or it is not a Interactive Terminal.

What it means

Thrown in the terminalInput handler when Terminal.getTerminal(terminalName) returns null or an object that is not an InteractiveTerminal. It means no interactive terminal is registered under the given name on the server, so the handler cannot write the command. This guards the terminal.write(cmd) call against an invalid target.

Source

Thrown at backend/agent-socket-handlers/terminal-socket-handler.ts:29

        agentSocket.on("terminalInput", async (terminalName : unknown, cmd : unknown, callback) => {
            try {
                checkLogin(socket);

                if (typeof(terminalName) !== "string") {
                    throw new Error("Terminal name must be a string.");
                }

                if (typeof(cmd) !== "string") {
                    throw new Error("Command must be a string.");
                }

                let terminal = Terminal.getTerminal(terminalName);
                if (terminal instanceof InteractiveTerminal) {
                    //log.debug("terminalInput", "Terminal found, writing to terminal.");
                    terminal.write(cmd);
                } else {
                    throw new Error("Terminal not found or it is not a Interactive Terminal.");
                }
            } catch (e) {
                callbackError(e, callback);
            }
        });

        // Main Terminal
        agentSocket.on("mainTerminal", async (terminalName : unknown, callback) => {
            try {
                checkLogin(socket);

                // Throw an error if console is not enabled
                if (!server.config.enableConsole) {
                    throw new ValidationError("Console is not enabled.");
                }

                // TODO: Reset the name here, force one main terminal for now
                terminalName = "console";

View on GitHub (pinned to f809ae192b)

Solutions

  1. Verify the terminal name matches one previously created via 'interactiveTerminal' or 'mainTerminal' on this connection.
  2. Re-create the terminal (e.g. re-emit 'interactiveTerminal') after any server restart or disconnect before sending input.
  3. Use the 'mainTerminal' event for the console terminal instead of 'terminalInput'.
  4. Add a client-side existence check/log of the terminal name being used.

Example fix

// before
socket.emit("terminalInput", "console", "ls");
// after
const name = "main-console"; // name used when creating the interactive terminal
socket.emit("terminalInput", name, "ls"); // or use socket.emit("mainTerminal", ...) for the console
Defensive patterns

Strategy: validation

Validate before calling

function assertTerminalExists(name, knownTerminals) { if (!knownTerminals.includes(name)) throw new Error(`Terminal "${name}" not created yet`); }
assertTerminalExists(terminalName, createdTerminals); socket.emit("terminalInput", terminalName, cmd);

Type guard

const hasTerminal = (name) => typeof name === "string" && createdTerminals.includes(name);

Try / catch

socket.emit("terminalInput", name, cmd, (res) => { if (res?.error) { recreateTerminal(name).then(() => retryInput(cmd)); } });

Prevention

When it happens

Trigger: Emitting 'terminalInput' with a terminalName that was never created, that was already removed/ended, or that refers to a non-interactive (e.g. main console) terminal.

Common situations: Client emits input after server restart (terminal registry lost), name mismatch between client and server (e.g. 'console' vs generated names), or writing to the main terminal via terminalInput instead of mainTerminal.

Related errors


AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31). Data as JSON: /api/errors/5ea139d854f69bb4. Report an issue: GitHub.