{"record":{"id":"139d8c6aa32b68e7","repo":"denoland/deno","slug":"cannot-get-pointer-size-unsupported-type-type","errorCode":null,"errorMessage":"Cannot get pointer size, unsupported type: ${type}","messagePattern":"Cannot get pointer size, unsupported type: (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/ffi/00_ffi.js","lineNumber":390,"sourceCode":"      return [1, 1];\n    case \"u16\":\n    case \"i16\":\n      return [2, 2];\n    case \"u32\":\n    case \"i32\":\n    case \"f32\":\n      return [4, 4];\n    case \"u64\":\n    case \"i64\":\n    case \"f64\":\n    case \"pointer\":\n    case \"buffer\":\n    case \"function\":\n    case \"usize\":\n    case \"isize\":\n      return [8, 8];\n    default:\n      throw new TypeError(`Cannot get pointer size, unsupported type: ${type}`);\n  }\n}\n\nclass UnsafeCallback {\n  #refcount;\n  // Internal promise only meant to keep Deno from exiting\n  #refpromise;\n  #rid;\n  definition;\n  callback;\n  pointer;\n\n  constructor(definition, callback) {\n    if (definition.nonblocking) {\n      throw new TypeError(\n        \"Cannot construct UnsafeCallback: cannot be nonblocking\",\n      );\n    }","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/ffi/00_ffi.js#L372-L408","documentation":"getTypeSizeAndAlignment maps each FFI type token to a size/alignment pair. Supported tokens are u8 i8 u16 i16 u32 i32 f32 u64 i64 f64 pointer buffer function usize isize, plus { struct: [...] } objects. Any other value reaches the default branch and throws with the offending value interpolated, which makes the message double as a debugging hint.","triggerScenarios":"Misspelled or non-Deno type names in struct fields or size-computed contexts: \"uint8\", \"int\", \"float\", \"double\", \"size_t\", \"int32\" (ffi-napi style), \"bool\", \"void\" inside a struct; passing a number, undefined, or an array where a type token is expected.","commonSituations":"Porting C headers verbatim; reusing type strings from Node's ffi-napi or napi bindings; generated bindings emitting C names; copy-paste edits that leave a placeholder value in a field list.","solutions":["Replace C/ffi-napi names with Deno tokens: int32->i32, uint8->u8, float->f32, double->f64, size_t->usize, pointers->pointer","Use \"void\" only as a function result type, never inside struct fields or where a size must be computed","Read the interpolated value in the message to locate the offending field, then fix that exact token"],"exampleFix":"// before\nconst Point = { struct: [\"float\", \"float\"] }; // TypeError: unsupported type: float\n\n// after\nconst Point = { struct: [\"f32\", \"f32\"] };","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const FFI_SCALARS = new Set([\n  \"u8\", \"i8\", \"u16\", \"i16\", \"u32\", \"i32\", \"f32\",\n  \"u64\", \"i64\", \"f64\", \"pointer\", \"buffer\", \"function\", \"usize\", \"isize\",\n]);\n\nconst isFfiType = (t) =>\n  FFI_SCALARS.has(t) ||\n  (typeof t === \"object\" && t !== null && Array.isArray(t.struct) &&\n    t.struct.every(isFfiType));\n\nif (!isFfiType(field)) throw new Error(`bad FFI type: ${String(field)}`);","tryCatchPattern":null,"preventionTips":["Use Deno's type tokens (i32, u8, f64, usize, pointer), not C or ffi-napi names","Reserve \"void\" for function result types only","Validate generated bindings with an allowlist before dlopen"],"tags":["ffi","type-definition","invalid-type"],"backgroundTag":"invalid-type-name","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"}