denoland/deno · error · Error
No callback function supplied
Error message
No callback function supplied
What it means
The callback form of fs.fstat expects (fd[, options], callback). When the callback slot is not a function - typically options passed as the second argument with no third argument - it throws the plain Error 'No callback function supplied' before any I/O happens.
Source
Thrown at ext/node/polyfills/_fs/_fs_fstat.ts:63
isFifo: stat.isFifo,
isSocket: stat.isSocket,
};
}
function fstat(
fd,
optionsOrCallback,
maybeCallback,
) {
fd = lazyFsUtils().getValidatedFd(fd);
const callback = typeof optionsOrCallback === "function"
? optionsOrCallback
: maybeCallback;
const options = typeof optionsOrCallback === "object"
? optionsOrCallback
: { bigint: false };
if (!callback) throw new Error("No callback function supplied");
PromisePrototypeThen(
op_node_fs_fstat(fd),
(stat) =>
callback(
null,
lazyStatUtils().CFISBIS(nodeFsStatToFileInfo(stat), options.bigint),
),
(err) => callback(denoErrorToNodeError(err, { syscall: "fstat" })),
);
}
function fstatSync(
fd,
options,
) {
fd = lazyFsUtils().getValidatedFd(fd);
try {View on GitHub (pinned to 89f33cbef2)
Solutions
- Add the callback: fs.fstat(fd, { bigint: true }, (err, stat) => ...)
- Use fs.promises.fstat(fd, { bigint: true }) with await
- Use fs.fstatSync(fd, { bigint: true }) for synchronous code
Example fix
// before
fs.fstat(fd, { bigint: true }); // Error: No callback function supplied
// after
import { fstat } from "node:fs/promises";
const stats = await fstat(fd, { bigint: true }); Defensive patterns
Strategy: type-guard
Validate before calling
function fstatArgs(
fd: number,
optionsOrCallback?: object | ((err: Error | null, stats?: unknown) => void),
maybeCallback?: (err: Error | null, stats?: unknown) => void,
) {
const callback = typeof optionsOrCallback === "function"
? optionsOrCallback
: maybeCallback;
const options = typeof optionsOrCallback === "object" ? optionsOrCallback : {};
if (typeof callback !== "function") {
throw new Error("fs.fstat requires a callback (or use fs.promises.fstat / fs.fstatSync)");
}
return { fd, options, callback };
} Type guard
function isCallback(v: unknown): v is (...args: unknown[]) => void {
return typeof v === "function";
} Prevention
- Prefer fs.promises.fstat in modern async code - no callback slot to forget
- When converting sync code, replace options-only calls with the *Sync or promises variant deliberately
- Lint for fs.* calls whose last argument is an object literal (a common dropped-callback smell)
When it happens
Trigger: fs.fstat(fd, { bigint: true }) with the callback forgotten; fs.fstat(fd) with neither options nor callback; options and callback supplied in the wrong order.
Common situations: Mechanical sync-to-async conversion that left options in the callback position; refactors that dropped the trailing callback; passing a variable that is undefined at runtime.
Related errors
- A file exists at the destination: ${destStr}
- ERR_MISSING_ARGS
- ERR_INVALID_ARG_TYPE
- No callback function supplied
- invalid ${name}, must not be infinity or NaN
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/9defa08fcb461895.
Report an issue: GitHub.