Skip to content

FileSystem.stat fails on Windows when NTFS inode exceeds Number.MAX_SAFE_INTEGER #8163

Closed

Description

@sam-goodwin

After #8110, Node FileSystem.stat uses { bigint: true } and converts identity metadata with Number(). If ino (or another field) is not a JS safe integer, the entire stat fails with BadArgument — including mtime, size, and type.

NTFS file indexes are 64-bit and routinely exceed Number.MAX_SAFE_INTEGER. That makes stat fail for ordinary files on Windows.

File.Info.ino is already Option<number>. An optional identity field that does not fit in number should be Option.none(), not a failed stat. size / blksize already take the preserve-exact path via ByteSize; optional numeric metadata should take the Option path.

Required dev / mode can stay fail-closed.

// packages/platform/node-shared/src/NodeFileSystem.ts
const bigintToNumberOption = (value: bigint | undefined, field: string): Option.Option<number> =>
  Option.map(Option.fromNullishOr(value), (value) => bigintToNumber(value, field))
  // bigintToNumber throws RangeError → makeFileInfo → BadArgument

On Windows this surfaces as BadArgument: ino exceeds the safe integer range: <64-bit file id> for a 10-byte temp file. We hit it in Alchemy's Cloudflare runtime registry after upgrading to [email protected]: live registry entries were treated as missing because stat (used only for mtime) failed.

Happy to send a PR that:

  • returns Option.none() for overflowed optional fields (ino, nlink, uid, gid, rdev, blocks)
  • keeps rejecting unsafe required dev / mode
  • updates the NodeFileSystem precision tests and the File.Info docs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions