How to call DynamicPlugins.unloadPlugin() without triggering SlowOperations assertions on EDT?

Hi there, I use the DynamicPlugins.unloadPlugin() api. It is allowed from Event Dispatch Thread (EDT) only, but it will throw java.lang.Throwable: Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc.

Now I call it like this, but it will throw java.lang.Throwable: Slow operations are prohibited on EDT. See SlowOperations.assertSlowOperationsAreAllowed javadoc..How to resolve it ?

ApplicationManager.getApplication().invokeLater(() -> {
    ReadAction.run(() -> {
        descriptorImpl.setEnabled(false);
        DynamicPlugins.INSTANCE.unloadPlugin(descriptorImpl)
    });
});

Hello!

DynamicPlugins API is internal and must not be used outside of IntelliJ Platform itself.

What is the rationale behind unloading an arbitrary plugin? Unless there is a good reason, your plugin might not get approval on JetBrains Marketplace when published.

Thanks for reply, I developed two plugins. Plugin A will unload plugin B in some special scenarios, such as user info is invalid, making plug-in B unusable.
Disable plugin need to restart IDE to take effect, so I use the DynamicPlugins.INSTANCE.unloadPlugin.

That is definitely not something we can allow plugins to do. Please do not use APIs for plugin management as versions with such usage will not get approved.

What do you want to do exactly? It’s like you’re trying to enable some features on demand. If so, there are better solutions.