Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension needs to be notified when it gets uninstalled #35006

Closed
akaroml opened this issue Sep 26, 2017 · 8 comments
Closed

Extension needs to be notified when it gets uninstalled #35006

akaroml opened this issue Sep 26, 2017 · 8 comments
Assignees
Labels
extensions Issues concerning extensions feature-request Request for new features or functionality on-testplan
Milestone

Comments

@akaroml
Copy link
Member

akaroml commented Sep 26, 2017

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.

@vscodebot vscodebot bot added the extensions Issues concerning extensions label Sep 26, 2017
@akaroml akaroml changed the title Extension needs to be notified when it gets uninstalling Extension needs to be notified when it gets uninstalled Sep 26, 2017
@sandy081
Copy link
Member

@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.

@aeschli FYI

@sandy081 sandy081 added the info-needed Issue requires more information from poster label Sep 26, 2017
@sandy081 sandy081 self-assigned this Sep 26, 2017
@vscodebot
Copy link

vscodebot bot commented Oct 3, 2017

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.

@vscodebot vscodebot bot closed this as completed Oct 3, 2017
@Luiz-N
Copy link

Luiz-N commented Oct 9, 2017

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).

@sandy081
Copy link
Member

Makes sense

@sandy081 sandy081 reopened this Oct 10, 2017
@sandy081 sandy081 added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Oct 10, 2017
@sandy081 sandy081 added this to the Backlog milestone Oct 10, 2017
@sandy081
Copy link
Member

sandy081 commented Jan 9, 2018

Related #14444

@sandy081
Copy link
Member

sandy081 commented Feb 21, 2018

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.

@GabrielBB
Copy link

GabrielBB commented Mar 11, 2018

@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?

@sandy081
Copy link
Member

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

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions feature-request Request for new features or functionality on-testplan
Projects
None yet
Development

No branches or pull requests

4 participants