# Plugin unload fails due to status bar widget

**URL:** <https://platform.jetbrains.com/t/plugin-unload-fails-due-to-status-bar-widget/3687>\
**Category:** IntelliJ Platform\
**Created:** [February 13, 2026, 5:23pm UTC](https://platform.jetbrains.com/t/plugin-unload-fails-due-to-status-bar-widget/3687 "2026-02-13T17:23:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abrooksv](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/abrooksv/32/924_2.png) [@abrooksv](https://platform.jetbrains.com/u/abrooksv)\
**Post date:** [February 13, 2026, 5:23pm UTC](https://platform.jetbrains.com/t/plugin-unload-fails-due-to-status-bar-widget/3687/1 "2026-02-13T17:23:52Z")

</div>

I have a status bar widget registered via `com.intellij.openapi.wm.StatusBarWidgetFactory`

but it seems to be the cause of a leak:

```auto
2026-02-13 09:07:24,878 [18624] INFO - #c.i.i.p.DynamicPlugins - Snapshot analysis result: Root 1:
  ROOT: Global JNI
  (root): com.intellij.openapi.wm.impl.IdeFrameImpl
  frameHelper: com.intellij.openapi.wm.impl.ProjectFrameHelper$1
  this$0: com.intellij.openapi.wm.impl.IdeProjectFrameHelper
  statusBar: com.intellij.openapi.wm.impl.status.IdeStatusBarImpl
  rightPanelLayout: java.awt.GridBagLayout
  componentAdjusting: com.intellij.openapi.wm.impl.status.IconPresentationComponent
  presentation: com.datadog.intellij.statusbar.StatusIcon
  <class>: java.lang.Class
* packageName: com.intellij.ide.plugins.cl.PluginClassLoader

```

I still see the icon in the status bar after the unload failure, does the platform not handle removal of widgets on unload?

---

<div class="post-metadata">

**Author:** ![abrooksv](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/abrooksv/32/924_2.png) [@abrooksv](https://platform.jetbrains.com/u/abrooksv)\
**Post date:** [February 13, 2026, 5:59pm UTC](https://platform.jetbrains.com/t/plugin-unload-fails-due-to-status-bar-widget/3687/2 "2026-02-13T17:59:35Z")

</div>

Ah, I found the code for it. I think it may be that I was using the passed in scope in the `com.intellij.openapi.wm.StatusBarWidgetFactory#createWidget(com.intellij.openapi.project.Project, kotlinx.coroutines.CoroutineScope)` which is `CoroutineName(com.intellij.openapi.wm.impl.status.widget.StatusBarWidgetsManager)`

and not the plugin coroutine scope like I was expecting so some of the flows seem to be staying alive

Widget creation:

> <https://github.com/JetBrains/intellij-community/blob/1e05f4447723efe125034ffad6a3764387893163/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/widget/StatusBarWidgetsManager.kt#L252-L257>

My code path hits line 253, and so it doesn’t create a child scope like `WidgetPresentationWrapper` does (which does cancel the `${factory.id}-widget` scope on disposable of the wrapper)

so it looks like a StatusBarWidgetFactory that is not also a `WidgetPresentationFactory` can leak coroutine scopes on plugin unload

---

<div class="post-metadata">

**Author:** ![dmitry.batkovich](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/dmitry.batkovich/32/202_2.png) [@dmitry.batkovich](https://platform.jetbrains.com/u/dmitry.batkovich)\
**Post date:** [February 13, 2026, 8:12pm UTC](https://platform.jetbrains.com/t/plugin-unload-fails-due-to-status-bar-widget/3687/3 "2026-02-13T20:12:11Z")

</div>

Hi Austin, nice catch! I created [https://youtrack.jetbrains.com/issue/IJPL-234915/StatusBarWidgetFactorycreateWidget-coroutine-scope-should-be-plugin-scoped-otherwise-it-can-break-dynamic-unload](https://youtrack.jetbrains.com/issue/IJPL-234915/StatusBarWidgetFactorycreateWidget-coroutine-scope-should-be-plugin-scoped-otherwise-it-can-break-dynamic-unload) . We will plan to fix it soon.

---

<div class="post-metadata">

**Author:** ![abrooksv](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/abrooksv/32/924_2.png) [@abrooksv](https://platform.jetbrains.com/u/abrooksv)\
**Post date:** [February 17, 2026, 3:38pm UTC](https://platform.jetbrains.com/t/plugin-unload-fails-due-to-status-bar-widget/3687/4 "2026-02-17T15:38:32Z")

</div>

@dmitry.batkovich I saw [this](https://github.com/JetBrains/intellij-community/commit/f08e0b7915a353bee1d900716ea41ebcbda9ebd8) land, but shouldn’t it be this:

```auto
private fun createWidget(
  factory: StatusBarWidgetFactory,
  dataContext: WidgetPresentationDataContext,
  parentScope: CoroutineScope,
): StatusBarWidget {
  val widgetScope = parentScope.childScope("${factory.id}-widget")
  tryAttachWidgetScopeToPlugin(factory, widgetScope)

  if (factory !is WidgetPresentationFactory) {
    return factory.createWidget(dataContext.project, widgetScope)
  }

  return WidgetPresentationWrapper(id = factory.id, factory = factory, dataContext = dataContext, scope = widgetScope)
}

```

?

Though that still will leak on manual removal of a widget for the stable status bar API types, same as the status quo today, since removal of a widget doesn’t have access to the coroutine scope and the default behavior does not cancel the scope on dispose, which the `WidgetPresentationWrapper` does handle for the widget factory
