Skip to content

Re-adopting a camera leaks the previous AmcrestCamera controller #22

Description

@calebcall

Found during the final review of #12 (detection-zone filtering). Pre-existing — not introduced by that work, and out of scope for it.

AmcrestPlugin.initCamera does this.cameras.set(camera.id, controller) (src/index.ts:335) without destroying whatever controller was already registered under that id. If both configureCameras and onCameraAdded fire for the same camera, or a camera is re-adopted without a release in between, the first controller stays alive and unreferenced.

The orphan keeps its event-stream connection, its reconnect timer and its RTSP relay running. The zone-subscription added in #15 is one more thing it holds.

Fix: destroy any existing controller for that id before replacing it.

this.cameras.get(camera.id)?.destroy();
this.cameras.set(camera.id, controller);

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions