denoland/deno · error · Error

No callback function supplied

Error message

No callback function supplied

What it means

fs.lstat(path, [options], callback) throws this plain Error (no error code) when no callback can be resolved: the callback is taken from optionsOrCallback if that is a function, otherwise from maybeCallback. It is a pure API-misuse error meaning you used the callback-based fs.lstat without supplying one.

Source

Thrown at ext/node/polyfills/_fs/_fs_lstat.ts:35

const {
  Error,
  PromisePrototypeThen,
  ObjectPrototypeIsPrototypeOf,
} = primordials;

function lstat(
  path,
  optionsOrCallback,
  maybeCallback,
) {
  const callback = typeof optionsOrCallback === "function"
    ? optionsOrCallback
    : maybeCallback;
  const options = typeof optionsOrCallback === "object"
    ? optionsOrCallback
    : { bigint: false };

  if (!callback) throw new Error("No callback function supplied");

  // Match Node: errors carry the requested path (see lib/fs.js lstat).
  const validatedPath = lazyFsUtils().getValidatedPathToString(path);
  PromisePrototypeThen(
    Deno.lstat(validatedPath),
    (stat) => callback(null, lazyStatUtils().CFISBIS(stat, options.bigint)),
    (err) => {
      // Match Node: `{ throwIfNoEntry: false }` suppresses ENOENT and yields
      // undefined stats (see lib/fs.js lstat()).
      if (
        options?.throwIfNoEntry === false &&
        ObjectPrototypeIsPrototypeOf(Deno.errors.NotFound.prototype, err)
      ) {
        callback(null, undefined);
        return;
      }
      callback(
        denoErrorToNodeError(err, {

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Use fs.promises.lstat(path, options) if you want a Promise
  2. Otherwise append a callback: fs.lstat(path, (err, stats) => { ... })
  3. Make sure the callback is passed as the argument right after options, not nested inside the options object

Example fix

// before
fs.lstat(path, { bigint: true });

// after
fs.promises.lstat(path, { bigint: true });
// or
fs.lstat(path, { bigint: true }, (err, stats) => { if (err) throw err; });
Defensive patterns

Strategy: validation

Validate before calling

if (typeof maybeCallback !== 'function' && typeof optionsOrCallback !== 'function') {
  throw new Error('lstat requires a callback; use fs.promises.lstat for promises');
}

Type guard

const isCallback = (v) => typeof v === 'function';

Prevention

When it happens

Trigger: fs.lstat('/tmp') with one argument, or fs.lstat('/tmp', { bigint: true }) where the second argument is an options object and no third function argument follows.

Common situations: Developer intends the promise API but imports the callback-style fs.lstat; refactoring from fs.promises.lstat to fs.lstat and forgetting the callback; passing a null callback.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/45c812735f2b5796. Report an issue: GitHub.