Skip to content

fs.rmSync fails on read-only file with EPERM #52253

Closed

Description

@xmedeko

Preflight Checklist

Electron Version

43.0.0

What operating system(s) are you using?

Windows

Operating System Version

Windows 11

What arch are you using?

x64

Last Known Working Electron version

No response

Does the issue also appear in Chromium / Google Chrome?

No

Expected Behavior

fs.rmSync should delete the file even if it's read-only.

Actual Behavior

fs.rmSync in Electron preload (nodeIntegration: true) fails to delete read-only file with: EPERM, Permission denied (Note: Windows 11). See the Gits Fiddle. Press "Create RO file" and then "Remove RO file".

While fsPromises.rm removes the file OK.

Node.version in Electron 43.0.0 is 24.17.0. When I try it with standalone Node.js 24.17.0 from command line, then the file is deleted OK.

Testcase Gist URL

https://gist.github.com/5042e7e0b320461ca0bb86908239bd5b

Additional Information

Note:

  • I have not tried it in electron main process without nodeIntegration. This is not used in public code, just internal one and we want to keep it KISS.
  • It was working with some older Electron version.

Activity

  1. added theissue type on Jul 3, 2026
  2. moved this to 👀 Unsorted Items in 44-x-yon Jul 3, 2026
  3. moved this to 👀 Unsorted Items in 43-x-yon Jul 3, 2026
  4. nikwen commented on Jul 3, 2026

    @nikwen
    Member

    Thanks for reporting!

    I have not tried it in electron main process without nodeIntegration.

    Could you please test if that works and report back?

    It was working with some older Electron version.

    Would you be able to bisect which version broke it? That will help us find the problematic commit.

  5. xmedeko commented on Jul 3, 2026

    @xmedeko
    Author

    Last good: v39.8.10
    First bad: v40.0.0

    Same problem when using ipcRenderer and fs.rmSync in the main process. I've updated the Gist and added one more button "Remove RO file in main sync".

  6. nikwen commented on Jul 6, 2026

    @nikwen
    Member

    Thanks for testing!

    Would you be able to check which v40 alpha/beta/nightly version introduced the issue? You can switch Electron versions easily in Electron Fiddle. You can also bisect in Fiddle: View > Toggle Bisect Helper. (You might need to enable nightly versions in the Electron Fiddle settings.)

  7. xmedeko commented on Jul 7, 2026

    @xmedeko
    Author

    Bisect complete. Check the range 40.0.0-alpha.2...40.0.0-alpha.4. (40.0.0-alpha.3 is not in the Fiddle list).

    (BTW. I was aware about Fiddle Bisect, but I fist tried If major version upgrade like x.0.0 could cause such breaking change and it worked.)

  8. removed this from 44-x-yon Jul 8, 2026
  9. moved this from 👀 Unsorted Items to 🔄 Follow Up Before Stable in 43-x-yon Jul 8, 2026
  10. added
    tracking-upstreamPR is currently blocked upstream, but has something upstream that is tracking the issue as well
    on Jul 15, 2026
  11. added a commit that references this issue on Sep 21, 2026
    1e93884
  12. added 4 commits that reference this issue on Sep 23, 2026
    cd83b73
    5b5641f
    10601c6
    3f5158b
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

    43-x-ybug 🪲has-repro-gistIssue can be reproduced with code at https://gist.github.com/platform/windowstracking-upstreamPR is currently blocked upstream, but has something upstream that is tracking the issue as well

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions