Skip to content

[Bug]: Windows10: shell.trashItem fails with "Failed to create FileOperation instance" #29598

Closed as not planned

Description

@dscalzi

Preflight Checklist

Electron Version

13.1.1

What operating system are you using?

Windows

Operating System Version

Windows 10 Version 21H1 (OS Build 19043.985)

What arch are you using?

x64

Last Known Working Electron version

12.0.10 Deletes worked on 12.0.10 until I upgraded. Now reverting still produces the issue.

Expected Behavior

shell.trashItem should move the file at the specified path to the recycling bin without failure.

Actual Behavior

shell.trashItem fails in all cases with the error message: Failed to create FileOperation instance. The path to the file is correct and a file exists at the path.

Testcase Gist URL

https://gist.github.com/dscalzi/240bfd99d0de37efcc700d240133db5a

Additional Information

As noted, the exact same code functioned correctly on version 12.0.10. I am unable to complete an upgrade to v13 due to this issue.

Edit: After switching back to electron 12.0.10 on fiddle I am getting the same issue. I'm not sure why.. I am able to delete the file fine through the file explorer. The error message isnt very descriptive either.

I have only tested on Windows 10.

Activity

  1. dscalzi commented on Jun 12, 2021

    @dscalzi
    ContributorAuthor

    Possibly related? #28748

  2. zcbenz commented on Jun 16, 2021

    @zcbenz
    Contributor

    Do old versions <= 11 work?

  3. dscalzi commented on Jun 24, 2021

    @dscalzi
    ContributorAuthor

    @zcbenz no it did not work in 11 (had to switch back to shell.moveItemToTrash for 11).

    Not sure why it's failing.. is anyone able to try this on an up to date windows machine..? Or at least get it to dump an error log instead the ambiguous failure message.

  4. added a commit that references this issue on Jun 24, 2021
  5. nornagon commented on Jul 9, 2021

    @nornagon
    Contributor

    #28787 is in v13.0.0+ and v12.0.6+ so it doesn't seem likely that that PR is related.

  6. nornagon commented on Jul 9, 2021

    @nornagon
    Contributor

    Duplicate of #28831

  7. dscalzi commented on Jul 10, 2021

    @dscalzi
    ContributorAuthor

    @nornagon This is not a duplicate of that issue. The error messages are completely different. Change the file path to D:\\DeleteMe\\this.txt in my gist and you still get Uncaught (in promise) Error: Failed to create FileOperation instance. On top of that, my implementation always uses path utilities so the path is never in a non-windows format on windows machines.

    Please reopen...

  8. dscalzi commented on Jul 10, 2021

    @dscalzi
    ContributorAuthor

    Perhaps to bring some clarity to this a more useful error message could be added, ie exactly what went wrong (stacktrace) such that the FileOperation instance could not be created..?

  9. lishid commented on Jul 12, 2021

    @lishid
    Contributor

    I can repro as well. Only happens in renderer process. The error message is also Failed to create FileOperation instance.

    I'm working around this issue with an IPC to main process instead.

  10. 23 remaining items

  11. dscalzi commented on Jul 3, 2023

    @dscalzi
    ContributorAuthor

    AFAIK still an issue

  12. benbowler commented on Aug 22, 2023

    @benbowler

    Yes this is still an issue 22nd August

  13. electron-issue-triage commented on Nov 21, 2023

    @electron-issue-triage

    This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

  14. sytolk commented on Nov 21, 2023

    @sytolk

    bump

  15. electron-issue-triage commented on Feb 21, 2024

    @electron-issue-triage

    This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

  16. electron-issue-triage commented on Mar 23, 2024

    @electron-issue-triage

    This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

  17. added a commit that references this issue on Aug 13, 2025
  18. added a commit that references this issue on Sep 15, 2026
  19. added a commit that references this issue on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions