Skip to content

Fix terminal plugin: socket reference, PTY newlines, public mode auth #237

Description

@melvincarvalho

Summary

Three bugs found while testing the --terminal feature (v0.0.118):

1. Socket reference wrong for @fastify/websocket v8+

connection.socket doesn't exist — connection IS the socket in v8+.

// Bug:
const socket = connection.socket;
// Fix:
const socket = connection.socket || connection;

2. Missing carriage returns (newline issue)

Shell output sends \n but xterm.js expects \r\n. Without a real PTY, lines render with staircase indentation.

// Fix: convert \n to \r\n on stdout/stderr output
socket.send(data.toString().replace(/\n/g, '\r\n'));

3. Auth required even on --public servers

The terminal endpoint always requires authentication, even when JSS is started with --public. Should respect the public flag.

4. /bin/sh vs /bin/bash -i

/bin/sh without a PTY doesn't show a prompt. Using /bin/bash -i (interactive mode) provides a prompt and better experience.

Long-term fix

Use node-pty for proper pseudo-terminal support instead of raw child_process.spawn. This would fix newlines, prompt, and interactive program support (vim, top, etc.) properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions