{"record":{"id":"cd6db297cf92e60b","repo":"oven-sh/bun","slug":"invalid-unix-path-path","errorCode":null,"errorMessage":"Invalid UNIX path: ${path}","messagePattern":"Invalid UNIX path: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bun-debug-adapter-protocol/src/debugger/signal.ts","lineNumber":92,"sourceCode":"   */\n  close(): void {\n    this.#server.close();\n  }\n}\n\nexport function randomUnixPath(): string {\n  return join(tmpdir(), `${randomBytes(16).toString(\"hex\")}.sock`);\n}\n\nfunction parseUnixPath(path: string | URL): string {\n  if (typeof path === \"string\" && path.startsWith(\"/\")) {\n    return path;\n  }\n  try {\n    const { pathname } = new URL(path);\n    return pathname;\n  } catch {\n    throw new Error(`Invalid UNIX path: ${path}`);\n  }\n}\n\nexport type TCPSocketSignalEventMap = {\n  \"Signal.listening\": [];\n  \"Signal.error\": [Error];\n  \"Signal.closed\": [];\n  \"Signal.received\": [string];\n  \"Signal.Socket.closed\": [socket: Socket];\n  \"Signal.Socket.connect\": [socket: Socket];\n};\n\nexport class TCPSocketSignal extends EventEmitter {\n  #port: number;\n  #server: ReturnType<typeof createServer>;\n  #ready: Promise<void>;\n\n  constructor(port: number) {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/packages/bun-debug-adapter-protocol/src/debugger/signal.ts#L74-L110","documentation":"Thrown by parseUnixPath() when the path passed to a UnixSignal debug-adapter server is neither an absolute filesystem string (starting with '/') nor a value the URL constructor can parse. The adapter must bind a concrete UNIX domain socket, so ambiguous or relative input is rejected up front. Note that on non-POSIX platforms (Windows) there is no absolute '/' path, so nearly any string fails or yields a useless pathname.","triggerScenarios":"Constructing new UnixSignal(path) with a relative string like './bun-debug.sock', a Windows path like 'C:\\\\sock' or '\\\\\\\\.\\\\pipe\\\\x', an empty string, or a string that makes new URL(path) throw (e.g. 'bun-debug.sock').","commonSituations":"Running the Bun VS Code debugger tooling on Windows where UNIX sockets are not filesystem paths; passing a cwd-relative socket path; passing a value that is neither string nor URL (e.g. a number from config).","solutions":["Pass an absolute path, e.g. join(tmpdir(), 'name.sock')","Pass a parseable URL string such as 'unix:///tmp/foo.sock' (the pathname is extracted and used)","On Windows use the TCP-based TCPSocketSignal class instead of UnixSignal","Omit the argument so randomUnixPath() generates a valid absolute path for you"],"exampleFix":"// before\nnew UnixSignal('./bun-debug.sock'); // relative path -> throws\n\n// after\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nnew UnixSignal(join(tmpdir(), 'bun-debug.sock'));","handlingStrategy":"validation","validationCode":"import { isAbsolute } from 'node:path';\n\nfunction canParseUnixPath(path: string | URL): boolean {\n  if (typeof path !== 'string') return path instanceof URL;\n  if (path.startsWith('/')) return true;\n  try { new URL(path); return true; } catch { return false; }\n}\n\nif (!canParseUnixPath(socketPath)) throw new TypeError(`bad unix socket path: ${String(socketPath)}`);","typeGuard":"function isUnixSocketPath(path: unknown): path is string | URL {\n  if (path instanceof URL) return true;\n  if (typeof path !== 'string') return false;\n  if (path.startsWith('/')) return true;\n  try { new URL(path); return true; } catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Always build socket paths with join(tmpdir(), name) instead of relative strings","On Windows, select the TCP signal class, never UnixSignal","Never pass numbers/objects from config; coerce to a validated string first"],"tags":["debugger","unix-socket","path","vscode"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}