You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli): sweep the adapter markers a deleted script leaves behind
The javascript adapter keeps two bookkeeping states beside every script, on every
javascript instance rather than only the one that runs it:
javascript.<n>.scriptEnabled.<id>
javascript.<n>.scriptProblem.<id>
Both are created by the adapter's load(), which calls createActiveObject and
createProblemObject before prepareScript checks common.engine to decide whether
this instance should run the script at all. Every instance runs load() for every
non-global script at startup and again on every source change, so all of them hold
a pair for every script.
Deletion, though, is gated on the engine: only the instance that owned the script
at the moment it was deleted removes its own pair. Every other instance keeps one
for a script that no longer exists, js-controller warns about it for the life of
the system, and nothing in ioBroker ever collects it. This is independent of who
deleted the script — the Admin UI leaves the identical residue.
remove, rename and move now sweep both markers of the id they just deleted. The
sweep runs after the object is gone and after the trash backup, and is best-effort:
it warns rather than turning a completed delete into a failure. Order is enforced
in ObjectsApi.deleteScriptMarker — value first, object second, never the reverse,
because an object deleted out from under a surviving value is exactly the orphan
being cleaned up. (The adapter's own cleanup gets this backwards, which is a likely
source of the "state has no object" warnings.)
remove also stops refusing an id whose script is already gone when markers remain,
since otherwise pre-existing ones cannot be cleared by anything. It sweeps them,
touches nothing else, and keeps the local file.
doctor gains a read-only `markers` check that counts both kinds, names the orphans,
and warns rather than fails — nothing here is broken.
Both kinds are handled through MARKER_KINDS in types.ts rather than a pattern
repeated per call site: an earlier draft covered only scriptEnabled and left eight
orphaned scriptProblem states on a live instance while doctor reported it clean.
Verified against ioBroker.javascript v8.9.2 on a live three-instance system, and
covered by tests against the in-process fake server.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|`init`| Write `.iobroker-sync.json`, verify the connection, create the script folder. Asks interactively when run without flags. `--types` also sets up TypeScript definitions. |
114
-
|`types`| Set up editor intellisense (`log`, `schedule`, ...). `--force`, `--offline`. |
115
-
|`login` / `logout`| Save or remove the password for this instance. Never stored in the project. |
116
-
|`trust`| Accept the instance's current TLS certificate. Only needed after it changes. `--yes` skips the prompt. |
117
-
|`doctor`| Check config, certificate, login, connection and a live round-trip, and say which one is wrong. Read-only, never prompts. Run this first when something looks broken.|
118
-
|`pull [pattern]`| Download scripts to disk. Never deletes or overwrites local files. |
|`init`| Write `.iobroker-sync.json`, verify the connection, create the script folder. Asks interactively when run without flags. `--types` also sets up TypeScript definitions. |
114
+
|`types`| Set up editor intellisense (`log`, `schedule`, ...). `--force`, `--offline`. |
115
+
|`login` / `logout`| Save or remove the password for this instance. Never stored in the project. |
116
+
|`trust`| Accept the instance's current TLS certificate. Only needed after it changes. `--yes` skips the prompt. |
117
+
|`doctor`| Check config, certificate, login, connection, a live round-trip and leftover adapter markers, and say which one is wrong. Read-only, never prompts. Run this first when something looks broken. |
118
+
|`pull [pattern]`| Download scripts to disk. Never deletes or overwrites local files. |
|`new <path>`| Create a new script (disabled) plus any missing folders. |
133
+
|`rename` / `move` / `remove`| Destructive. Require `--yes` and back up the object first. `remove` keeps the local file unless `--delete-local`. All three also clean up the `scriptEnabled`/`scriptProblem` states the old id leaves behind on every javascript instance. |
134
134
135
135
`--dry-run`, `--verbose`, `--json` and `-C <dir>` are global and work with every command.
136
136
When in doubt, `--dry-run` shows what would happen and changes nothing.
0 commit comments