Skip to content

fix(cli): time out when the DMS server doesn't answer - #3791

Merged
bbedward merged 2 commits into
duxlabs-dev:masterfrom
Conava:cli-server-timeout
Oct 15, 2026
Merged

bbedward merged 2 commits into
duxlabs-dev:masterfrom
Conava:cli-server-timeout

Conversation

@Conava

@Conava Conava commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds a timeout to the CLI's connection to the DMS server.

sendServerRequest and sendServerRequestFireAndForget dialed the socket with no deadline. If the server process is stopped or stuck, the socket still accepts connections, so every command that goes through the server (clipboard, dms open, matugen queue, icc, qr) hangs forever waiting for the greeting. matugen queue without --wait is the worst case, since the shell runs it on every theme change: before, it didn't check for the greeting at all, so it reported success and never fell back to running matugen itself.

Changes:

  • Connecting, reading the greeting and sending the request now time out after 2 seconds, the same limit the qsipc client uses.
  • A missing greeting is an error now, so the fire-and-forget fallback kicks in.
  • The wait for the reply has no limit, as before, since matugen queue --wait can take up to its own 90 second timeout.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor / internal cleanup
  • Documentation
  • Other

Related issues

None.

Screenshots / video

Checklist

Tested against a fake socket that accepts but never answers: dms clipboard history hangs on master and exits after 2 seconds with "server did not respond" on this branch. The new tests in server_client_test.go cover both the silent server and a slow reply that still has to succeed. go test ./..., the FreeBSD cross-build and all pre-commit hooks pass. No QML, no new strings, no docs needed.

The CLI's server client dialed the socket with no deadline. If the
server process is stopped or stuck, the kernel still accepts the
connection, so every server-first command (clipboard, open, matugen
queue, icc, qr, notify actions) waited forever for the greeting. The
fire-and-forget path ignored the missing greeting too, so matugen queue
reported success and never fell back to running matugen itself.

Bound dialing, the greeting and the request write by 2 seconds, like
the qsipc client does, and treat a missing greeting as an error. The
wait for the reply stays unbounded, because matugen queue --wait can
take up to its own 90 second timeout.
@bbedward

Copy link
Copy Markdown
Member

/claude review

Comment thread core/cmd/dms/server_client.go Resolved
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Claude review

Looks good; one minor error-message glitch.

  • Clean EOF before greeting yields %!w(<nil>) in the error, core/cmd/dms/server_client.go:37
    Checked: handshake deadline set/cleared around greeting and request write, reply left unbounded, fire-and-forget fallback in matugen queue, all CLI callers' payload sizes vs the 2s write deadline, conn close on error paths, new tests. Model: claude-opus-5-5.

A server that accepts and closes before the greeting left scanner.Err()
nil, so the error read "server did not respond: %!w(<nil>)". Fall back
to io.EOF and test the closed connection.
@bbedward

Copy link
Copy Markdown
Member

/claude review

@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Claude review

No issues found. The earlier %!w(<nil>) comment is fixed with the io.EOF fallback and covered by a test.
Checked: handshake deadline set before the greeting and cleared before the unbounded reply read, conn closed on every error path, fire-and-forget now fails on a missing greeting so the matugen queue fallback runs, and the new fake-server tests. Model: claude-opus-5-5.

@bbedward
bbedward merged commit e2ecc1f into duxlabs-dev:master Oct 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants