Skip to content

Bug: HMR orphans Tauri event listeners in App.tsx service singletons #1936

@Liohtml

Description

@Liohtml

Summary

app/src/App.tsx starts five service singletons at module evaluation time (startWebviewAccountService(), etc.). These attach Tauri listen<>() event handlers internally. During Vite HMR, module re-evaluation is guarded by started flags (preventing double-start), but orphaned listeners from the previous module instance are never cleaned up.

Impact

Low — Development-only: HMR accumulates orphaned event listeners, causing duplicate handler execution and potential memory leaks during hot reload cycles.

Suggested Fix

Export cleanup functions from each service and call them in import.meta.hot?.dispose():

if (import.meta.hot) {
  import.meta.hot.dispose(() => {
    stopWebviewAccountService();
    stopWebviewNotificationsService();
    // ...
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions