Skip to content

Windows support: hardcoded /tmp/ paths break on Windows #43

@tucaman

Description

@tucaman

Problem

surf-cli hardcodes Unix socket paths as /tmp/surf.sock across 4 files in native/. On Windows, /tmp/ doesn't exist and Unix domain sockets aren't supported, so every surf command fails with:

Error: Socket not found. Is Chrome running with the extension?

This is the same user-facing error as #42, but with a different root cause — on Windows the socket path itself is invalid, whereas #42 reports the issue on macOS where the path is valid but the socket isn't being created.

Affected files

File Hardcoded path
native/cli.cjs const SOCKET_PATH = "/tmp/surf.sock"
native/do-executor.cjs const SOCKET_PATH = "/tmp/surf.sock"
native/host.cjs const SOCKET_PATH = "/tmp/surf.sock" + const LOG_FILE = "/tmp/surf-host.log"
native/mcp-server.cjs const SOCKET_PATH = "/tmp/surf.sock"

Proposed fix

Use Windows named pipes on win32 and os.tmpdir() on Unix:

const SOCKET_PATH = process.platform === "win32"
  ? "\\.\pipe\surf-sock"
  : path.join(os.tmpdir(), "surf.sock");

This approach:

  • Uses Windows named pipes (\.\pipe\surf-sock) which are the Windows equivalent of Unix domain sockets
  • Falls back to os.tmpdir() instead of hardcoded /tmp/ for better cross-platform support on Unix too
  • Requires adding os and path imports to do-executor.cjs and mcp-server.cjs (already present in the other files)

Environment

  • Windows 11 Pro
  • Node.js v22
  • surf-cli installed via npm install -g

I have a PR ready with the fix — will link it here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions