debug: add PTY lifecycle logging
- Log PTY PID and shell when spawned - Log all PTY output data - Log PTY exit events with exit code and signal - Log when WebSocket cannot send PTY data This will help identify if the PTY is exiting immediately or if there's an issue with the PTY process.
This commit is contained in:
@@ -67,6 +67,8 @@ class TerminalService {
|
||||
env: process.env
|
||||
});
|
||||
|
||||
console.log(`[TerminalService] PTY spawned with PID: ${pty.pid}, shell: ${shell}`);
|
||||
|
||||
// Store terminal info
|
||||
const terminal = {
|
||||
id: terminalId,
|
||||
@@ -140,17 +142,20 @@ class TerminalService {
|
||||
|
||||
// Handle PTY output - send to client
|
||||
terminal.pty.onData((data) => {
|
||||
console.log(`[TerminalService] PTY data from ${terminalId}: ${data.replace(/\n/g, '\\n').replace(/\r/g, '\\r')}`);
|
||||
if (ws.readyState === ws.OPEN) {
|
||||
ws.send(JSON.stringify({
|
||||
type: 'data',
|
||||
data: data
|
||||
}));
|
||||
} else {
|
||||
console.log(`[TerminalService] Cannot send PTY data - WebSocket not open (state: ${ws.readyState})`);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle PTY exit
|
||||
terminal.pty.onExit(({ exitCode, signal }) => {
|
||||
console.log(`[TerminalService] Terminal ${terminalId} exited: ${exitCode || signal}`);
|
||||
console.log(`[TerminalService] PTY EXIT for ${terminalId}: exitCode=${exitCode}, signal=${signal}`);
|
||||
this.logCommand(terminalId, null, `Terminal exited: ${exitCode || signal}`);
|
||||
|
||||
if (ws.readyState === ws.OPEN) {
|
||||
|
||||
Reference in New Issue
Block a user