snapshot: fix periodic snapshot timeout regression

This commit is contained in:
Koushik Dutta
2024-03-05 08:57:14 -08:00
parent 09c8c114f7
commit 73607fd1aa
3 changed files with 7 additions and 6 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/snapshot",
"version": "0.2.39",
"version": "0.2.40",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/snapshot",
"version": "0.2.39",
"version": "0.2.40",
"dependencies": {
"@types/node": "^20.10.6",
"sharp": "^0.33.1",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/snapshot",
"version": "0.2.39",
"version": "0.2.40",
"description": "Snapshot Plugin for Scrypted",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",

View File

@@ -292,12 +292,13 @@ class SnapshotMixin extends SettingsMixinDeviceBase<Camera> implements Camera {
if (periodicSnapshot && this.currentPicture) {
const cp = this.currentPicture;
debounced.catch(() => { });
const timeout = options.timeout || 1000;
try {
picture = await (options.timeout ? timeoutPromise(options.timeout, debounced) : debounced);
picture = await timeoutPromise(timeout, debounced);
}
catch (e) {
if (options.timeout)
this.debugConsole?.log(`Periodic snapshot took longer than ${options.timeout} seconds to retrieve, falling back to cached picture.`)
if (e instanceof TimeoutError)
this.debugConsole?.log(`Periodic snapshot took longer than ${timeout} seconds to retrieve, falling back to cached picture.`)
picture = cp;
}