{"record":{"id":"2a2297435a1a9c15","repo":"paperclipai/paperclip","slug":"native-so-peercred-is-supported-only-on-linux","errorCode":null,"errorMessage":"native SO_PEERCRED is supported only on Linux","messagePattern":"native SO_PEERCRED is supported only on Linux","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailscale-https-broker/src/native-peercred.ts","lineNumber":23,"sourceCode":" * build compiles a dependency-free N-API addon next to this module's emitted\n * JavaScript. The native call is synchronous and runs once per accepted local\n * socket, before the connection enters the admission pool.\n */\nimport { createRequire } from \"node:module\";\nimport type { Socket } from \"node:net\";\nimport type { PeerCredentials } from \"./types.js\";\n\ninterface NativePeercredBinding {\n  getPeerCredentials(fd: number): PeerCredentials;\n}\n\ninterface SocketWithHandle extends Socket {\n  _handle?: { fd?: unknown };\n}\n\nexport function createNativePeerCredentialReader(): (socket: Socket) => PeerCredentials {\n  if (process.platform !== \"linux\") {\n    throw new Error(\"native SO_PEERCRED is supported only on Linux\");\n  }\n\n  const require = createRequire(import.meta.url);\n  const binding = require(\"./peercred-native.node\") as NativePeercredBinding;\n\n  return (socket: Socket): PeerCredentials => {\n    const fd = (socket as SocketWithHandle)._handle?.fd;\n    if (!Number.isInteger(fd) || (fd as number) < 0) {\n      throw new Error(\"accepted socket has no valid file descriptor\");\n    }\n    return binding.getPeerCredentials(fd as number);\n  };\n}\n","sourceCodeStart":5,"sourceCodeEnd":37,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/tailscale-https-broker/src/native-peercred.ts#L5-L37","documentation":"Platform gate in createNativePeerCredentialReader: the N-API addon that reads SO_PEERCRED could not be loaded/initialized, or the process is running on a non-Linux platform where SO_PEERCRED does not exist. The Unix-socket peer-credential model is Linux-only, so the broker cannot provide its core admission guarantee here.","triggerScenarios":"Thrown at packages/tailscale-https-broker/src/native-peercred.ts:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the broker on Linux to use native SO_PEERCRED, or disable the native peercred path on other platforms."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}