mirror of
https://github.com/koush/scrypted.git
synced 2026-03-20 16:40:24 +00:00
snapshot: enforce a 5s timeout for web requests
This commit is contained in:
20
plugins/snapshot/package-lock.json
generated
20
plugins/snapshot/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/snapshot",
|
||||
"version": "0.2.38",
|
||||
"version": "0.2.39",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/snapshot",
|
||||
"version": "0.2.38",
|
||||
"version": "0.2.39",
|
||||
"dependencies": {
|
||||
"@types/node": "^20.10.6",
|
||||
"sharp": "^0.33.1",
|
||||
@@ -26,24 +26,23 @@
|
||||
"dependencies": {
|
||||
"@scrypted/sdk": "file:../sdk",
|
||||
"@scrypted/server": "file:../server",
|
||||
"http-auth-utils": "^3.0.2",
|
||||
"node-fetch-commonjs": "^3.1.1",
|
||||
"http-auth-utils": "^5.0.1",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.10.8",
|
||||
"@types/node": "^20.11.0",
|
||||
"ts-node": "^10.9.2"
|
||||
}
|
||||
},
|
||||
"../../sdk": {
|
||||
"name": "@scrypted/sdk",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.14",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"adm-zip": "^0.4.13",
|
||||
"axios": "^0.21.4",
|
||||
"axios": "^1.6.5",
|
||||
"babel-loader": "^9.1.0",
|
||||
"babel-plugin-const-enum": "^1.1.0",
|
||||
"esbuild": "^0.15.9",
|
||||
@@ -838,9 +837,8 @@
|
||||
"requires": {
|
||||
"@scrypted/sdk": "file:../sdk",
|
||||
"@scrypted/server": "file:../server",
|
||||
"@types/node": "^20.10.8",
|
||||
"http-auth-utils": "^3.0.2",
|
||||
"node-fetch-commonjs": "^3.1.1",
|
||||
"@types/node": "^20.11.0",
|
||||
"http-auth-utils": "^5.0.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
@@ -852,7 +850,7 @@
|
||||
"@types/node": "^18.11.18",
|
||||
"@types/stringify-object": "^4.0.0",
|
||||
"adm-zip": "^0.4.13",
|
||||
"axios": "^0.21.4",
|
||||
"axios": "^1.6.5",
|
||||
"babel-loader": "^9.1.0",
|
||||
"babel-plugin-const-enum": "^1.1.0",
|
||||
"esbuild": "^0.15.9",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/snapshot",
|
||||
"version": "0.2.38",
|
||||
"version": "0.2.39",
|
||||
"description": "Snapshot Plugin for Scrypted",
|
||||
"scripts": {
|
||||
"scrypted-setup-project": "scrypted-setup-project",
|
||||
|
||||
@@ -291,7 +291,7 @@ class SnapshotMixin extends SettingsMixinDeviceBase<Camera> implements Camera {
|
||||
// the debounce has already triggered a refresh for the next go around.
|
||||
if (periodicSnapshot && this.currentPicture) {
|
||||
const cp = this.currentPicture;
|
||||
debounced.catch(() => {});
|
||||
debounced.catch(() => { });
|
||||
try {
|
||||
picture = await (options.timeout ? timeoutPromise(options.timeout, debounced) : debounced);
|
||||
}
|
||||
@@ -682,8 +682,13 @@ export class SnapshotPlugin extends AutoenableMixinProvider implements MixinProv
|
||||
const search = new URLSearchParams(pathname.split('?')[1]);
|
||||
const mixin = this.mixinDevices.get(id);
|
||||
let buffer: Buffer;
|
||||
let timeout = parseInt(search.get('timeout'));
|
||||
// make web requests timeout after 5 seconds by default.
|
||||
if (isNaN(timeout))
|
||||
timeout = 5000;
|
||||
const rpo: RequestPictureOptions = {
|
||||
reason: search.get('reason') as 'event' | 'periodic',
|
||||
timeout,
|
||||
picture: {
|
||||
width: parseInt(search.get('width')) || undefined,
|
||||
height: parseInt(search.get('height')) || undefined,
|
||||
|
||||
Reference in New Issue
Block a user