Skip to content

Temporary .ico files created by NativeImage should be cleaned #22500

Closed

Description

@raksooo

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 7.1.10
  • Operating System:
    • Windows 10 (1909)

Expected Behavior

Temporary .tmp.ico files created by NativeImage in \Users\<user>\AppData\Local\Temp\ should be cleaned after NativeImage is destroyed or when application exits.

Actual Behavior

The .tmp.ico file is left in \Users\<user>\AppData\Local\Temp. If the application is opened multiple times there are multiple temporary icons.

To Reproduce

  1. Create a NativeImage with an .ico file archived in an asar-archive
  2. Start the application
    2a. Check that a .tmp.ico file was created in \Users\<user>\AppData\Local\Temp\
  3. Quit the application
    3a. Notice that the file wasn't deleted

Additional Information

This is related to #10796 with the difference that #10796 answered whether or not the files could be deleted and didn't address that they should be deleted automatically.

The code doing the copying:
https://github.com/electron/electron/blob/v1.8.1/atom/common/api/atom_api_native_image.cc#L168-L184

Activity

  1. pronebird commented on Mar 3, 2020

    @pronebird

    Would it be possible to load icon directly from ASAR instead of dumping it to disk first?

  2. MarshallOfSound commented on Mar 3, 2020

    @MarshallOfSound
    Member

    Because these files are created in Temp they can (and will) be cleaned by the OS whenever it wants to. Them being left behind is ok as the OS will clean this folder up.

  3. pronebird commented on Mar 4, 2020

    @pronebird

    @MarshallOfSound there is absolutely no way this can be addressed in the future by reading the ICO directly from memory (asar) vs. extracting it to filesystem? Seems like you dismiss the case without consideration. I realise you guys have plenty of work to do besides dealing with this, but sounds like a good improvement either way.

  4. Gitoffthelawn commented on Apr 8, 2026

    @Gitoffthelawn

    Can this be re-opened please? It's still an issue. Windows does not automatically empty the system temp folder when third-party apps leave orphaned files in that folder. It relies on apps to clean up their own mess.

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