denoland/deno · error

not supported

Error message

not supported

What it means

FsError::NotSupported (JS error class 'not_supported', a TypeError, message 'not supported'; ext/io/fs.rs:72) is returned when the concrete file resource cannot perform the requested operation: reads (read/readAll) against stdout/stderr resources, and File-trait operations on unsupported platforms — for example chown on Windows (implemented only for unix) and stat on targets that are neither unix nor windows.

Source

Thrown at ext/io/fs.rs:72

impl std::error::Error for FsError {}

impl FsError {
  pub fn kind(&self) -> io::ErrorKind {
    match self {
      Self::Io(err) => err.kind(),
      Self::FileBusy => io::ErrorKind::Other,
      Self::NotSupported => io::ErrorKind::Other,
      Self::PermissionCheck(e) => e.kind(),
      Self::JoinError(_) => io::ErrorKind::Other,
    }
  }

  pub fn into_io_error(self) -> io::Error {
    match self {
      FsError::Io(err) => err,
      FsError::FileBusy => io::Error::new(self.kind(), "file busy"),
      FsError::NotSupported => io::Error::new(self.kind(), "not supported"),
      FsError::PermissionCheck(err) => err.into_io_error(),
      FsError::JoinError(ref err) => {
        io::Error::new(self.kind(), format!("join error: {err}"))
      }
    }
  }
}

impl From<io::Error> for FsError {
  fn from(err: io::Error) -> Self {
    Self::Io(err)
  }
}

impl From<io::ErrorKind> for FsError {
  fn from(err: io::ErrorKind) -> Self {
    Self::Io(err.into())
  }

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Never read stdout/stderr — capture output by spawning with Deno.Command and stdout: 'piped'
  2. Gate ownership ops on the platform: only call chown when Deno.build.os !== 'windows'
  3. Feature-check with a benign operation before relying on platform-specific file ops

Example fix

// before
for await (const chunk of Deno.stdout.readable) { /* ... */ }
// TypeError: not supported

// after
const cmd = new Deno.Command(Deno.execPath(), {
  args: ['run', 'child.ts'],
  stdout: 'piped',
});
const { stdout } = await cmd.output();
Defensive patterns

Strategy: type-guard

Validate before calling

const isWritableStdio = (rid: number): boolean =>
  rid === Deno.stdout.rid || rid === Deno.stderr.rid;

async function readResource(rid: number, buf: Uint8Array): Promise<number | null> {
  if (isWritableStdio(rid)) {
    throw new Error(`rid ${rid} is stdout/stderr and cannot be read; pipe a child process instead`);
  }
  // proceed with a read on a readable resource
  return readViaApi(rid, buf);
}

Type guard

function isReadableStreamLike(f: Deno.FsFile | Deno.File): boolean {
  return ![Deno.stdout.rid, Deno.stderr.rid].includes(f.rid);
}

const chownSupported = (): boolean => Deno.build.os !== 'windows';

Try / catch

try {
  await file.chown(uid, gid);
} catch (e) {
  if (e instanceof TypeError && /not supported/i.test(e.message)) {
    console.warn('chown is unavailable on this platform');
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Reading from a stdout/stderr resource (iterating Deno.stdout.readable, or any API that calls read on the stdout/stderr rid); calling file-chown operations on a Windows handle; hitting the non-unix/non-windows cfg arms of the stdio File implementation.

Common situations: Trying to 'capture' output by reading Deno.stdout.readable instead of piping a child process; scripts assuming Unix semantics for ownership ops; code that treats every rid as a general-purpose file.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/7a2199b9b8364185. Report an issue: GitHub.