Skip to content

fix: clear watcher registry in disableAll - #6145

Open
zloglevel wants to merge 2 commits into
Unitech:masterfrom
zloglevel:master
Open

fix: clear watcher registry in disableAll#6145
zloglevel wants to merge 2 commits into
Unitech:masterfrom
zloglevel:master

Conversation

@zloglevel

@zloglevel zloglevel commented Aug 18, 2026

Copy link
Copy Markdown
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

Summary

God.watch._watchers is initialized as an object keyed by pm_id, but
God.watch.disableAll() previously attempted to remove entries with
Array.prototype.splice().

When the watcher registry is non-empty, the first watcher is closed and the method then throws:

TypeError: watchers.splice is not a function

This prevents the remaining watchers from being closed and removed.

Changes

  • Replace the invalid splice() call with Object.keys() iteration and
    property deletion.
  • Add a regression test with two fake watchers.
  • Verify that each watcher is closed exactly once.
  • Verify that the watcher registry is empty after disableAll() completes.

Testing

npx mocha --exit --bail test/interface/watcher.spec.mocha.js

Result: 1 passing.

Signed-off-by: zloglevel <loglevel@outlook.com>
@CLAassistant

CLAassistant commented Aug 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@zloglevel

Copy link
Copy Markdown
Author

@Unitech Could you please take a look when you have a chance? Thanks!

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

Labels

None yet

2 participants