Skip to content

Conversation

@cebtenzzre
Copy link
Contributor

@cebtenzzre cebtenzzre commented Nov 8, 2025

Problem

Commit 2239e58 ("Merge branch 'context-managers'") from 4.5.12 caused regressions in app initialization.

  • Apps would no longer load with production_mode: true because the async task races with initialization, and check_app_updates() is never called again.
  • Even in debug mode, app initialization became non-deterministic.

The system would log "App initialization complete" but apps weren't actually loaded yet (or ever, in production mode).

Root Cause

The old app_management.start() method used loop.create_task() to initialize apps asynchronously:

def start(self):
    self.AD.loop.create_task(self.init_admin_entities())
    task = self.AD.loop.create_task(
        self.check_app_updates(mode=UpdateMode.INIT),
        name="check_app_updates",
    )
    task.add_done_callback(lambda _: ...)

This created a race where apps might not be loaded before the system continued. In production mode, where check_app_updates() is skipped in the utility loop, apps would never load if the task hadn't completed yet.

Solution

app_management.start() is replaced with a synchronous version. Scheduler initialization and app loading are moved back to the end of Utility._init_loop.

Two regression tests are added to verify that production mode is once again functional.


Fixes #2442
Fixes #2467

@mmattel
Copy link
Contributor

mmattel commented Nov 11, 2025

@jsl12 @acockburn note, if this gets merged, a new AD version should be created and published...

Copy link
Contributor

@jsl12 jsl12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@acockburn acockburn merged commit d70d939 into AppDaemon:dev Nov 16, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Production mode not loading apps App not starting in 4.5.12

4 participants