{"record":{"id":"e551c259b5c0d4cd","repo":"denoland/deno","slug":"err-fs-cp-unknown","errorCode":"ERR_FS_CP_UNKNOWN","errorMessage":"Cannot copy an unknown file type","messagePattern":"Cannot copy an unknown file type","errorType":"exception","errorClass":"SystemError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/_fs/cp/cp.ts","lineNumber":116,"sourceCode":"      });\n    case \"SOCKET\":\n      throw new ERR_FS_CP_SOCKET({\n        message: err.message,\n        path: err.path,\n        syscall: \"cp\",\n        errno: EINVAL,\n        code: \"EINVAL\",\n      });\n    case \"FIFO\":\n      throw new ERR_FS_CP_FIFO_PIPE({\n        message: err.message,\n        path: err.path,\n        syscall: \"cp\",\n        errno: EINVAL,\n        code: \"EINVAL\",\n      });\n    case \"UNKNOWN\":\n      throw new ERR_FS_CP_UNKNOWN({\n        message: err.message,\n        path: err.path,\n        syscall: \"cp\",\n        errno: EINVAL,\n        code: \"EINVAL\",\n      });\n    case \"SYMLINK_TO_SUBDIRECTORY\":\n      throw new ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY({\n        message: err.message,\n        path: err.path,\n        syscall: \"cp\",\n        errno: EINVAL,\n        code: \"EINVAL\",\n      });\n    default:\n      throw err;\n  }\n}","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/_fs/cp/cp.ts#L98-L134","documentation":"If the source stat matches none of the known kinds (file, char/block device, symlink, socket, FIFO, directory), the native cp dispatch falls through to CpError::Unknown (kind 'UNKNOWN'), which throwCpError maps to ERR_FS_CP_UNKNOWN ('Cannot copy an unknown file type', errno EINVAL). fs.cp deliberately refuses anything it cannot classify so exotic entries are not silently dropped or mis-copied.","triggerScenarios":"Copying trees containing doors or event ports (Solaris-style IPC), weird FUSE/9p mount entries whose st_mode is unusual, or entries whose type changed between stat and dispatch; recursive copies over /proc- or /sys-backed paths on Linux.","commonSituations":"Container volume copies over pseudo-filesystems; cross-platform scripts hitting platform-specific file types; race conditions where an entry is replaced mid-copy (stat saw one kind, dispatch sees none of the known ones).","solutions":["Enumerate and copy only entries you can classify: lstat each entry and skip/flag anything that is not file/dir/symlink","Copy from a stable snapshot (tar the tree first) to avoid mid-copy type races","Report the offending path from err.path and handle it specially instead of recursing blindly"],"exampleFix":"// before\nfs.cp(mountPoint, 'out', { recursive: true }, cb); // unknown st_mode entry\n\n// after — copy only classifiable entries\nfor (const name of fs.readdirSync(mountPoint)) {\n  const p = path.join(mountPoint, name);\n  const st = fs.lstatSync(p);\n  if (st.isFile() || st.isDirectory() || st.isSymbolicLink()) {\n    fs.cpSync(p, path.join('out', name), { recursive: true });\n  } else {\n    console.warn('skipping unclassifiable entry', p);\n  }\n}","handlingStrategy":"validation","validationCode":"const copyable = (p) => { const st = fs.lstatSync(p); return st.isFile() || st.isDirectory() || st.isSymbolicLink(); };","typeGuard":"const isKnownCopyType = (st) => st.isFile() || st.isDirectory() || st.isSymbolicLink() || st.isCharacterDevice() || st.isBlockDevice();","tryCatchPattern":"try { await fs.promises.cp(src, dest, { recursive: true }); } catch (e) { if (e.code === 'ERR_FS_CP_UNKNOWN') { console.warn('unclassifiable entry', e.path); /* fall back to explicit per-entry copy */ } else throw e; }","preventionTips":["Don't recursive-copy pseudo-filesystems (/proc, /sys, FUSE mounts)","Snapshot with tar first when entries may mutate mid-copy","Whitelist entry kinds instead of assuming stat covers everything"],"tags":["node-compat","fs","cp","copy","err-fs-cp-unknown","file-type","deno"],"backgroundTag":"fs-cp-unsupported-file-type","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}