{"record":{"id":"869654329386cbf3","repo":"denoland/deno","slug":"using-cpu-features-module-is-currently-not-support","errorCode":null,"errorMessage":"Using cpu-features module is currently not supported","messagePattern":"Using cpu-features module is currently not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/01_require.js","lineNumber":2314,"sourceCode":"\n// Async hooks wrappers for NAPI - called from Rust via V8 function calls.\nfunction napiAsyncHooksEmitInit(asyncId, type, triggerAsyncId, resource) {\n  internalAsyncHooksEmitInit(asyncId, type, triggerAsyncId, resource);\n}\nfunction napiAsyncHooksEmitBefore(asyncId) {\n  internalAsyncHooksEmitBefore(asyncId);\n}\nfunction napiAsyncHooksEmitAfter(asyncId) {\n  internalAsyncHooksEmitAfter(asyncId);\n}\nfunction napiAsyncHooksEmitDestroy(asyncId) {\n  internalAsyncHooksEmitDestroy(asyncId);\n}\n\n// Native extension for .node\nModule._extensions[\".node\"] = function (module, filename) {\n  if (filename.endsWith(\"cpufeatures.node\")) {\n    throw new Error(\"Using cpu-features module is currently not supported\");\n  }\n  module.exports = op_napi_open(\n    filename,\n    globalThis,\n    buffer.Buffer.from,\n    reportError,\n    napiAsyncHooksEmitInit,\n    napiAsyncHooksEmitBefore,\n    napiAsyncHooksEmitAfter,\n    napiAsyncHooksEmitDestroy,\n  );\n};\n\nfunction createRequireFromPath(filename, sourceURL) {\n  const proxyPath = op_require_proxy_path(filename) ?? filename;\n  const mod = new Module(proxyPath);\n  mod.filename = proxyPath;\n  mod.paths = Module._nodeModulePaths(mod.path);","sourceCodeStart":2296,"sourceCodeEnd":2332,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/01_require.js#L2296-L2332","documentation":"Deno's .node native-extension loader explicitly blocks the cpu-features package: any path ending in cpufeatures.node throws before op_napi_open runs. cpu-features is an optional native dependency - most commonly pulled in by ssh2 - that inspects CPU details in a way Deno's runtime does not support.","triggerScenarios":"require('cpu-features') resolving to a prebuilt cpufeatures.node, directly or through ssh2/ssh2-streams loading it; occurs at first require, not at install time, so the dependency can slip through npm install successfully.","commonSituations":"ssh2 in the dependency tree (it lists cpu-features as an optional dependency); a fresh npm install fetching optional native deps; CI images that differ from local machines in which optional modules get built.","solutions":["Reinstall without optional dependencies: npm install --omit=optional (or remove cpu-features from package.json / lockfile)","Upgrade or pin ssh2 to a version that degrades gracefully when cpu-features is absent","Replace the native dependency with a pure-JS alternative where feasible"],"exampleFix":"# before\nnpm install\nnode -e \"require('ssh2')\"  # may load cpu-features -> Error\n\n# after\nnpm install --omit=optional\nnode -e \"require('ssh2')\"","handlingStrategy":"try-catch","validationCode":"// Install-time check: fail with a clear message before runtime\n// npm ls cpu-features || echo 'optional dep absent (good)'","typeGuard":"function isBlockedNativeModule(filename: string): boolean {\n  return filename.endsWith('.node') && filename.endsWith('cpufeatures.node');\n}","tryCatchPattern":"let cpuFeatures;\ntry {\n  cpuFeatures = require('cpu-features');\n} catch (e) {\n  if (e instanceof Error && e.message.includes('cpu-features')) {\n    cpuFeatures = undefined; // optional acceleration - continue without it\n  } else {\n    throw e;\n  }\n}","preventionTips":["Install with --omit=optional in Dockerfiles and CI when the tree contains ssh2","Audit lockfiles for cpu-features after dependency updates","Treat native optional deps as accelerations only - always keep a pure-JS fallback path"],"tags":["deno","node-compat","napi","native-module","ssh2"],"backgroundTag":"unsupported-native-module","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"}