Skip to content

fs.access() not reporting error on Windows #19192

Description

@dougwit
  • Version: 9.6.1
  • Platform: Windows 7 Professional x64
  • Subsystem: fs

fs.access() returns no error when given a file/directory with no priveleges.

Code example:

'use strict'

const fs = require('fs')

fs.access('./restricted', fs.constants.R_OK || fs.constants.W_OK, err => {
  if (err) {
    console.log(err)
  } else {
    console.log('no access() error')
  }
})

fs.stat('./restricted', (err, stat) => {
  if (err) {
    console.log(err)
  } else {
    console.log('no stat() error')
  }
})

Output:

no access() error
{ Error: EPERM: operation not permitted
  errno: -4048,
  code: 'EPERM',
  syscall: 'stat',
  path: 'C:\\Workspaces\\restricted' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.fsIssues and PRs related to file-system APIs and the fs module.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions