Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapter abstürze #603

Open
flockinger opened this issue Oct 25, 2023 · 9 comments
Open

Adapter abstürze #603

flockinger opened this issue Oct 25, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@flockinger
Copy link

Hallo,
der Ring Adapter stürzt mir mehrmals täglich ab. Manchmal alle paar Minuten, manchmal mehrere Stunden nicht.
Im Log finde ich dieses:

2023-10-25 09:05:18.874 - error: ring.0 (9419) Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
2023-10-25 09:05:18.874 - error: ring.0 (9419) unhandled promise rejection: (0 , rxjs_1.firstValueFrom) is not a function
2023-10-25 09:05:18.875 - error: ring.0 (9419) TypeError: (0 , rxjs_1.firstValueFrom) is not a function
at OwnRingCamera.takeHDSnapshot (/opt/iobroker/node_modules/iobroker.ring/build/lib/ownRingCamera.js:519:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async OwnRingCamera.conditionalRecording (/opt/iobroker/node_modules/iobroker.ring/build/lib/ownRingCamera.js:780:53)
2023-10-25 09:05:18.875 - error: ring.0 (9419) (0 , rxjs_1.firstValueFrom) is not a function
2023-10-25 09:05:18.877 - info: ring.0 (9419) terminating
2023-10-25 09:05:18.877 - warn: ring.0 (9419) Terminated (UNCAUGHT_EXCEPTION): Without reason
2023-10-25 09:05:19.378 - info: ring.0 (9419) terminating

jscontroller 5.0.14
Ring 5.0.1
Debian 10 auf Proxmox 7.4-17

theimo1221 added a commit that referenced this issue Oct 25, 2023
* (theimo1221) Remove mixup of callback and async within same function
* (theimo1221) #603 Harden usage of "firstValueFrom"
@theimo1221
Copy link
Collaborator

Nabend @flockinger
bitte mit Version 5.0.2 neu prüfen.

@flockinger
Copy link
Author

Moin,
danke für Deine schnelle Reaktion.
Hab 5.0.2 grade installiert, mal den Tag abwarten.

@flockinger
Copy link
Author

flockinger commented Oct 26, 2023

Jetzt mit V5.0.2:

2023-10-26 09:08:41.686 - error: ring.0 (8274) Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
2023-10-26 09:08:41.688 - error: ring.0 (8274) unhandled promise rejection: (0 , rxjs_1.firstValueFrom) is not a function
2023-10-26 09:08:41.688 - error: ring.0 (8274) TypeError: (0 , rxjs_1.firstValueFrom) is not a function
at OwnRingCamera.takeHDSnapshot (/opt/iobroker/node_modules/iobroker.ring/build/lib/ownRingCamera.js:162:67)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async OwnRingCamera.conditionalRecording (/opt/iobroker/node_modules/iobroker.ring/build/lib/ownRingCamera.js:856:53)
2023-10-26 09:08:41.688 - error: ring.0 (8274) (0 , rxjs_1.firstValueFrom) is not a function
2023-10-26 09:08:41.690 - info: ring.0 (8274) terminating
2023-10-26 09:08:41.691 - warn: ring.0 (8274) Terminated (UNCAUGHT_EXCEPTION): Without reason
2023-10-26 09:08:42.193 - info: ring.0 (8274) terminating
2023-10-26 09:08:42.236 - error: host.iobroker instance system.adapter.ring.0 terminated with code 6 (UNCAUGHT_EXCEPTION)

@theimo1221
Copy link
Collaborator

@crocri could you take a look as u created HD-Snapshots?

@crocri
Copy link
Contributor

crocri commented Oct 26, 2023

Sure :-)
If I look into "my" original ownRingCamera.ts it's different to yours. Return value from "await firstValueFrom(liveCall.onCallEnded)" is the first value from stream, nothing to do with true or false (have a look at rxjs library). So please do nothing with this await, nor catch an error, this will not work as expected. I'm using this in the same way as ring api do (simply wait, nothing else).
One or two rows above, the output setting is also different to mine. The duration time is not needed any longer for HD Snapshot, because it takes the first I-Frame from the stream after start time (much better than take a B or P-Frame)

@theimo1221
Copy link
Collaborator

theimo1221 commented Oct 26, 2023

@flockinger had the issues in 5.0.1 which didn't include my hardening changes from yesterday evening here: f1b8300

Here I added the catch, to properly handle existing and upcomming rejections from the this._ringDevice.streamVideo call:

const liveCall = await this._ringDevice.streamVideo({
video: this.videoFilter(this._adapter.config.overlay_HDsnapshot, night_contrast ? this._adapter.config.contrast_HDsnapshot : 0),
// output: ["-t", duration.toString(), "-f", "mjpeg", "-q:v", 3, "-frames:v", 1, tempPath]
output: ["-f", "mjpeg", "-q:v", 3, "-frames:v", 1, tempPath]
}).catch(reason => {
this.catcher("Couldn't create HD Snapshot.", reason);
return null;
});
if (!liveCall) {
this.warn(`Couldn't create HD Snapshot`);
await this.updateHDSnapshotRequest(false);
return;
}

This doesn`t modify the result of the normal resolve.

The following snippet is your version (same as 5.0.1) which especially only awaits the firstValueOf which accordingly to @flockinger crashed:

const liveCall = await this._ringDevice.streamVideo({
video: this.videoFilter(this._adapter.config.overlay_HDsnapshot, night_contrast ? this._adapter.config.contrast_HDsnapshot : 0),
// output: ["-t", duration.toString(), "-f", "mjpeg", "-q:v", 3, "-frames:v", 1, tempPath]
output: ["-f", "mjpeg", "-q:v", 3, "-frames:v", 1, tempPath]
})
await firstValueFrom(liveCall.onCallEnded);
if (!fs.existsSync(tempPath)) {
this.warn(`Couldn't create HD Snapshot`);
await this.updateHDSnapshotRequest(false);
return;
} else {
this.silly(`HD Snapshot from livestream created`);
}

In 5.0.2 I tried to log what/why it crashes I added the then/catch cases and processed the result of it, which itself shouldn't change the behaviour wihtin firstValueFrom but only process it's outcome.

const liveCallSucceeded = await firstValueFrom(liveCall.onCallEnded).then(_result => {
return true;
}).catch(reason => {
this.catcher("Couldn't create HD Snapshot.", reason);
return null;
});
if (!fs.existsSync(tempPath) || !liveCallSucceeded) {
this.warn(`Couldn't create HD Snapshot`);
await this.updateHDSnapshotRequest(false);
return;
} else {
this.silly(`HD Snapshot from livestream created`);
}

For me this:

TypeError: (0 , rxjs_1.firstValueFrom) is not a function
at OwnRingCamera.takeHDSnapshot (/opt/iobroker/node_modules/iobroker.ring/build/lib/ownRingCamera.js:162:67)

seemed like the result of the livecall wasn't an observable, but it seems more like in @flockinger's case the function is somehow not bundled correctly within his rxjs...

What is your opinion on this @crocri ?

theimo1221 added a commit that referenced this issue Oct 26, 2023
* (theimo1221) #603 Change rxjs import to resolve awkward js build result.
@theimo1221
Copy link
Collaborator

I changed the rxjs import which results in the js build not beeing like this:

const liveCallSucceeded = await (0, rxjs_1.firstValueFrom)(liveCall.onCallEnded).then(_result => {

But instead like this:

const liveCallSucceeded = await rxjs.firstValueFrom(liveCall.onCallEnded).then(_result => {

Which could resolve the issue for you @flockinger

@flockinger
Copy link
Author

Hallo @theimo1221 ,
Mit 5.0.3 jeweils ein Absturz direkt nach Bewegungserkennung (vorher laufend Abstürze).

2023-10-27 03:24:50.683 - error: ring.0 (6310) Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
2023-10-27 03:24:50.684 - error: ring.0 (6310) unhandled promise rejection: rxjs.firstValueFrom is not a function
2023-10-27 03:24:50.684 - error: ring.0 (6310) TypeError: rxjs.firstValueFrom is not a function
at OwnRingCamera.takeHDSnapshot (/opt/iobroker/node_modules/iobroker.ring/build/lib/ownRingCamera.js:162:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async OwnRingCamera.conditionalRecording (/opt/iobroker/node_modules/iobroker.ring/build/lib/ownRingCamera.js:856:53)
2023-10-27 03:24:50.684 - error: ring.0 (6310) rxjs.firstValueFrom is not a function
2023-10-27 03:24:50.688 - info: ring.0 (6310) terminating
2023-10-27 03:24:50.688 - warn: ring.0 (6310) Terminated (UNCAUGHT_EXCEPTION): Without reason
2023-10-27 03:24:51.189 - info: ring.0 (6310) terminating
2023-10-27 03:24:51.219 - error: host.iobroker instance system.adapter.ring.0 terminated with code 6 (UNCAUGHT_EXCEPTION)

theimo1221 added a commit that referenced this issue Oct 27, 2023
* (theimo1221) #603 Add rxjs to normal dependencies instead of dev-dependencies
@crocri
Copy link
Contributor

crocri commented Oct 27, 2023

Hi!
Now it's look much better. Return value is now true or null. But in my opinion it's enough to check tempPath as result, not liveCallSucceeded. What if liveCallSucceded is true (= no error), but tempPath is still empty or file length is 0 bytes?
But nevertheless it's functioning now (just installed from github in ioBroker).

@mcm1957 mcm1957 added the bug Something isn't working label Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants