Skip to content

Commit

Permalink
cameras: fix signal + timeout combined usage
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Mar 28, 2024
1 parent 30f9e35 commit 3c1801a
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions plugins/amcrest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/amcrest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/amcrest",
"version": "0.0.143",
"version": "0.0.144",
"description": "Amcrest Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",
Expand Down
4 changes: 2 additions & 2 deletions plugins/hikvision/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/hikvision/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/hikvision",
"version": "0.0.145",
"version": "0.0.146",
"description": "Hikvision Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",
Expand Down
4 changes: 2 additions & 2 deletions plugins/onvif/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/onvif/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/onvif",
"version": "0.1.12",
"version": "0.1.13",
"description": "ONVIF Camera Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",
Expand Down
4 changes: 2 additions & 2 deletions plugins/reolink/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/reolink/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/reolink",
"version": "0.0.64",
"version": "0.0.65",
"description": "Reolink Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",
Expand Down
4 changes: 2 additions & 2 deletions plugins/snapshot/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/snapshot/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/snapshot",
"version": "0.2.41",
"version": "0.2.42",
"description": "Snapshot Plugin for Scrypted",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
Expand Down
7 changes: 2 additions & 5 deletions server/src/fetch/http-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export async function httpFetch<T extends HttpFetchOptions<Readable>>(options: T
if (options.timeout) {
controller = new AbortController();
timeout = setTimeout(() => controller.abort(), options.timeout);

options.signal?.addEventListener('abort', () => controller.abort('abort'));
}

const request = proto.request(url, {
Expand All @@ -109,11 +111,6 @@ export async function httpFetch<T extends HttpFetchOptions<Readable>>(options: T
timeout: options.timeout,
});

if (controller)
options.signal?.addEventListener('abort', () => controller.abort('abort'));
else
options.signal?.addEventListener('abort', () => request.destroy(new Error('abort')));

if (body)
body.pipe(request);
else
Expand Down
2 changes: 2 additions & 0 deletions server/src/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export async function domFetch<T extends HttpFetchOptions<BodyInit>>(options: T)
if (options.timeout) {
controller = new AbortController();
timeout = setTimeout(() => controller.abort(), options.timeout);

options.signal?.addEventListener('abort', () => controller.abort('abort'));
}

try {
Expand Down

0 comments on commit 3c1801a

Please sign in to comment.