Skip to content

Extension needs to be notified when it gets uninstalled #35006

Closed

Description

@akaroml

When an extension is uninstalled, it needs to be notified of the uninstall event and do some cleanup before it is removed.

Here's the scenario. We have extension B which register some Java component in extension A. So when B is uninstalled, we would like to unregister B from A. Otherwise, A would attempt to load B's Java component in the next run, when B is already removed.

In our case, A is the Java Language Support from RedHat. B is the new Java debugger from Microsoft. Both ship Java artifacts which contain the real logic. So it's very important for the registration/unregistration to happen correctly.

Activity

  1. changed the title [-]Extension needs to be notified when it gets uninstalling[/-] [+]Extension needs to be notified when it gets uninstalled[/+] on Sep 26, 2017
  2. sandy081 commented on Sep 26, 2017

    @sandy081
    Member

    Rome Li (@akaroml) Not sure why do you need to Uninstall listener here. Actually when an extension depends on another extension, you can add it as a dependency in extensionDependencies section of package.json. Dependent extension should not bother about the depending extensions existence or not. It should be other way round. We also make sure if an extension is uninstalled, we do not uninstall it if there is an extension depending on it.

    It looks to me that in your case B depends on A and A wants to do some clean up when B is uninstalled. This is showing some cyclic dependencies.

    Martin Aeschlimann (@aeschli) FYI

  3. vscodebot commented on Oct 3, 2017

    @vscodebot

    This issue has been closed automatically because it needs more information and has not had recent activity. Please refer to our guidelines for filing issues. Thank you for your contributions.

  4. Luiz-N commented on Oct 9, 2017

    @Luiz-N

    I have a different use case but the same request for an uninstall life-cycle hook/event. I have an extension that needs to clean up some dirs/files it creates on the OS when uninstalling but should leave alone if simply deactivating (closing a vscode instance).

  5. sandy081 commented on Oct 10, 2017

    @sandy081
    Member

    Makes sense

  6. added
    feature-requestRequest for new features or functionality
    and removed
    info-neededIssue requires more information from poster
    on Oct 10, 2017
  7. sandy081 commented on Jan 9, 2018

    @sandy081
    Member

    Related #14444

  8. sandy081 commented on Feb 21, 2018

    @sandy081
    Member

    Now you can provide node script (javascript) to run after the extension is uninstalled, using the property vscode:uninstall under the scripts property in package.json.

    Example

    "scripts": {
        "vscode:prepublish": "tsc -p ./",
        "vscode:uninstall": "node ./out/src/extensionUninstall"
    },

    Using this hook, you can clean up the stuff that your extension has created.

  9. GabrielBB commented on Mar 11, 2018

    @GabrielBB

    Sandeep Somavarapu (@sandy081) "Using this hook, you can clean up the stuff that your extension has created." I can't clean up vs code user settings on that hook. In my case, i add some settings. It says that it can not find 'vscode' module when that hook runs. Should i go the user.settings path and modify with plain node js?

  10. sandy081 commented on Mar 12, 2018

    @sandy081
    Member

    Gabriel Basilio (@GabrielBB) Yes, this hook does not provide you access to vscode api. Please create a new feature request for that.

  11. locked and limited conversation to collaborators on Apr 7, 2018
  12. added a commit that references this issue on Sep 6, 2026
    c5c1cc4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions