Skip to content

[BUG] Reloading @luna/lib causes dependency-order race and loads dependants before @luna/ui is available #196

Description

@Solomag

Prerequisites

Please check the following before continuing:

  • I have searched for existing issues, including closed issues to ensure this is not a duplicate.
  • This is a issue for the Luna Client and not a Plugin
  • I am running the latest Luna Client version (See latest release)

Environment

  • OS: Windows
  • TIDAL Version: 2.43.2.21-release (W: 2026.09.01) (NP: 3.1.5.322)
  • Luna Client Version: 1.16.6-beta

Description

Reloading @luna/lib causes a dependency-order race.

During the reload sequence, dependent plugins are unloaded, but some of them are loaded again before @luna/ui has finished loading and has been restored to luna.core.modules.

This causes repeated transient failures such as:

Error: Cannot find module @luna/ui in luna.core.modules

I can reproduce this consistently by repeatedly reloading only @luna/lib.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Start TIDAL with Luna.
  2. Open Luna Settings.
  3. Find @luna/lib.
  4. Click Reload.
  5. Open DevTools with Ctrl-Shift-I and watch the console.
  6. Repeat the reload several times.
  7. Observe dependent plugins trying to load before @luna/ui is available.

Expected Behavior

Reloading @luna/lib should restore its dependency chain in the correct order.

Plugins that depend on @luna/ui should only be loaded after @luna/ui has finished loading and is present in luna.core.modules.

The reload should complete without transient module-resolution failures.

Actual Behavior

After @luna/lib is reloaded, Luna starts loading several dependent plugins while @luna/ui is still unavailable.

For example:

[@luna/core].LunaPlugin[@luna/lib] Unloaded
[@luna/core].LunaPlugin[@luna/lib] Loaded

[@luna/core].LunaPlugin[@luna/lib] Loading dependant @luna/ui
[@luna/core].LunaPlugin[@luna/lib] Loading dependant @solomag/lunatic-ui
[@luna/core].LunaPlugin[@luna/lib] Loading dependant @luna/dev
[@luna/core].LunaPlugin[@luna/lib] Loading dependant DiscordRPC

This is followed by failures like:

[@luna/core].LunaPlugin[@solomag/lunatic-ui] [DEV] Failed to load
Error: Cannot find module @luna/ui in luna.core.modules

and:

[@luna/core].LunaPlugin[@luna/dev] Failed to load
Error: Cannot find module @luna/ui in luna.core.modules

The same can also happen to other plugins that depend on @luna/ui, such as DiscordRPC.

Shortly afterwards, @luna/ui finishes loading and the failed dependants are loaded again:

[@luna/core].LunaPlugin[@luna/ui] Loaded
[@luna/core].LunaPlugin[@luna/ui] Loading dependant @solomag/lunatic-ui
[@luna/core].LunaPlugin[@luna/ui] Loading dependant @luna/dev
[@luna/core].LunaPlugin[@luna/ui] Loading dependant DiscordRPC

So the final state can recover, but the reload sequence itself is racy and causes unnecessary failed loads.

Screenshots / Logs

To open console to view logs & errors press Ctrl-Shift-I.

Relevant log excerpt:

[@luna/core].LunaPlugin[@luna/lib] Unloaded
[@luna/core].LunaPlugin[@luna/lib] Loaded
[@luna/core].LunaPlugin[@luna/lib] Loading dependant @luna/ui
[@luna/core].LunaPlugin[@luna/lib] Loading dependant @solomag/lunatic-ui
[@luna/core].LunaPlugin[@luna/lib] Loading dependant @luna/dev
[@luna/core].LunaPlugin[@luna/lib] Loading dependant DiscordRPC

[@luna/core].LunaPlugin[@solomag/lunatic-ui] [DEV] Failed to load Error: Cannot find module @luna/ui in luna.core.modules
[@luna/core].LunaPlugin[@luna/dev] Failed to load Error: Cannot find module @luna/ui in luna.core.modules

[@luna/core].LunaPlugin[@luna/ui] Loaded
[@luna/core].LunaPlugin[@luna/ui] Loading dependant @solomag/lunatic-ui
[@luna/core].LunaPlugin[@luna/ui] Loading dependant @luna/dev
[@luna/core].LunaPlugin[@luna/ui] Loading dependant DiscordRPC

During repeated reloads I also observed secondary lifecycle issues such as:

[Luna.native] RemoteDesktopController is already running

and DiscordRPC connection timeouts.

These appear to be secondary effects of the cascading reload and are not necessary to reproduce the main issue.

Additional Context

This issue appears specifically when reloading @luna/lib.

For comparison, I also tested repeated reloads of @luna/ui and @luna/lib.native from clean TIDAL starts.

Reloading @luna/ui did not produce:

Cannot find module @luna/ui in luna.core.modules

Reloading @luna/lib.native was also clean and did not show the same dependency-order failure.

The main issue therefore seems specific to how @luna/lib reloads and restarts its dependants.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions