denoland/deno · error · TypeError
Cannot get pointer size, unsupported type
Error message
Cannot get pointer size, unsupported type: ${type} What it means
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.
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
Example fix
// before
const Point = { struct: ["float", "float"] }; // TypeError: unsupported type: float
// after
const Point = { struct: ["f32", "f32"] }; Defensive patterns
Strategy: type-guard
Type guard
const FFI_SCALARS = new Set([
"u8", "i8", "u16", "i16", "u32", "i32", "f32",
"u64", "i64", "f64", "pointer", "buffer", "function", "usize", "isize",
]);
const isFfiType = (t) =>
FFI_SCALARS.has(t) ||
(typeof t === "object" && t !== null && Array.isArray(t.struct) &&
t.struct.every(isFfiType));
if (!isFfiType(field)) throw new Error(`bad FFI type: ${String(field)}`); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot get pointer size: found recursive struct
- Cannot access pointer: expected 'ArrayBuffer'…
- Cannot construct UnsafeCallback: cannot be nonblocking
- Foreign symbol of type 'void' is not supported
- Initialize libloading failed
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/139d8c6aa32b68e7.
Report an issue: GitHub.
Appendix: source
Thrown at ext/ffi/00_ffi.js:390
return [1, 1];
case "u16":
case "i16":
return [2, 2];
case "u32":
case "i32":
case "f32":
return [4, 4];
case "u64":
case "i64":
case "f64":
case "pointer":
case "buffer":
case "function":
case "usize":
case "isize":
return [8, 8];
default:
throw new TypeError(`Cannot get pointer size, unsupported type: ${type}`);
}
}
class UnsafeCallback {
#refcount;
// Internal promise only meant to keep Deno from exiting
#refpromise;
#rid;
definition;
callback;
pointer;
constructor(definition, callback) {
if (definition.nonblocking) {
throw new TypeError(
"Cannot construct UnsafeCallback: cannot be nonblocking",
);
}View on GitHub (pinned to 9ad36f7a2c)