Fix strictNullChecks in runtime.ts and scrypted-server-main.ts:
- Change findPluginDevice return type to PluginDevice | undefined
- Add type assertions at call sites that expect valid results
- Consolidate assertions at variable declarations
- Use undefined! instead of undefined as any
- Use throw e instead of throw new Error(e as string)
- Add catch block type annotations (e: any)
- Fix socket property and plugin device lookups with assertions
Fix strictNullChecks in services:
- plugin.ts: assert findPluginDeviceById results at assignment point,
clean up scattered assertions throughout methods
- users.ts: make aclId parameter optional in addUserToDatabase/addUserInternal
- Make PluginRemote.loadZip options parameter optional to match implementations
- Add undefined to _protocols type in WebSocket class
- Add non-null assertions for device lookup in REPL server
- Add non-null assertion for eventInterface in acl.ts
- Add non-null assertion for SCRYPTED_CLUSTER_ADDRESS env var
- Use .flat() instead of [].concat() for type safety
- Add non-null assertion for ScryptedDevice descriptor access
- Use options! and null! assertions for mediaObject properties
- Initialize foundAny variable before use
- Add fallback for undefined env var in parseFloat
- Add non-null assertions for Map lookups and array indices
- Fix ClusterObject type annotation for undefined case
- Add non-null assertions for env vars and socket properties
- Add type assertions for event callbacks and timestamps
- Use non-null assertions for guaranteed object references
- Update notify signature to accept number | undefined for eventTime
- Preserve crash behavior for logger and refresh throttle access
- setStorage interface uses ScryptedNativeId to match implementation
- getDeviceById returns Promise<ScryptedDevice | undefined>
- Add non-null assertions where objects are guaranteed to exist
- Add explicit error throws for null checks with descriptive messages
- Add parseInt with empty string fallback for undefined env vars
- getIpAddress returns string | undefined when no addresses available
- Add type guard filters for network interface arrays
Previously, if this.serialize() threw an exception, result would be undefined
when passed to createErrorResult. This fix brings TypeScript in sync with the
Python rpc.py implementation which already initializes result before the try block.
Check serviceKey directly after parsing instead of checking existing?.serviceKey.
This fixes a bug where key parsing failures would be silently ignored.
The ReolinkCameraClient never called the Logout API before requesting a
new token, causing stale sessions to accumulate on the camera. When the
camera's session limit was reached (~68 min cycle), it would close the
RTMP/RTSP connection, dropping the stream.
Add a logout() method that releases the old token session before login()
requests a new one, matching the pattern already used by ReolinkNvrClient.
This prevents session buildup and eliminates periodic stream drops.
Fixes#1873
Co-authored-by: Josh Casada <joshcasada@Joshs-Mac-mini.ts.net lan>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>