Ensure instance monitoring objects (alive/connected) exist - #640
Open
krobipd wants to merge 1 commit into
Open
Conversation
On some upgraded installations the `system.adapter.<instance>.alive` and `.connected` objects are missing while their state values persist. The admin "Instances" tab then shows the instance red for a few seconds whenever the tab is opened, because its object-based state snapshot skips object-less states (ioBroker#603). Recreate the two objects idempotently on start via `setForeignObjectNotExistsAsync`, so healthy instances stay untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
The
devicesinstance is shown red in the admin Instances tab for a few seconds every time the tab is opened (or after a browser refresh), then turns green. It happens only fordevices, not for other adapters, and nothing is logged — even in debug. Reported in #603 and in the forum (topic 84587); the workaround users found was to delete and re-create the instance.Root cause
On the affected installations the instance monitoring objects
system.adapter.devices.<n>.aliveandsystem.adapter.devices.<n>.connectedare missing, while their state values still exist (js-controller keeps writing them via the heartbeat).When the Instances tab loads, its object-based state snapshot (
getForeignStates('system.adapter.*')) skips the object-less states, soalive/connectedare briefly absent from the admin's cache andgetInstanceStatus()evaluates!alive || !connected→ red. The live state subscription then delivers a heartbeat and the row turns green.This is specific to
devices: otherconnectionType: nonedaemon adapters (e.g.javascript) still have both objects. The current code neither deletes nor recreates them, so once they are gone (older version / upgrade) the situation persists.Fix
Recreate the two objects idempotently on start with
setForeignObjectNotExistsAsync, modeled on the standard instance-state objects (boolean, roleindicator.state). Healthy instances are left untouched; affected instances self-heal on the next start — no data loss, unlike delete-and-recreate.How it was verified
On a live system with the objects missing (red confirmed in Safari and Firefox):
getForeignStates('system.adapter.devices.0.*')returned the states again once the objects existed (it was empty before).npm run build:backendandeslintpass.Addresses #603.