Skip to content

close() leaves local mode armed; sends are silently swallowed #60

Description

@ctoth

Summary

MudClient.close() tears down the socket/stream but never clears localMode or localStream, so in WASM/local mode subsequent send() calls route into the dead stream and are silently swallowed while the user's command still echoes to the output pane.

Details

src/client.ts:284-301 closes the stream but leaves localMode/localStream set. send() (lines 248-255) then still takes the local branch:

public send(data: string) {
  if (this.localMode && this.localStream) {
    this.localStream.write(Buffer.from(data));
  } else {
    this.ws.send(data);
  }
}

sendCommand (line 303) has already added the command to the output store via addCommand when local echo is on, so the user sees their command and nothing is actually sent. On the WebSocket path the same silent-drop happens because send() on a CLOSED socket is a no-op.

Fix direction

Clear localMode/localStream in close()/cleanupConnection, and have send() surface an error (or refuse and notify) when there is no live transport instead of dropping silently.

Verification

Read src/client.ts end to end.

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