Closed krocheck closed 2 years ago
Why could that fail? What is the use case when it fails? I would like to try to reproduce it. TimeRemaining should always be seconds or miliseconds, right? I wonder if there is a more elegant way instead of the repeated try/catch way like check all the time variables when they come from OBS...
Unfortunately I have no information on the use-case. I'm just passing along an error that flagged. A proper test of the timeRemaining
would be great, but I can't shed any more light at this moment.
https://sentry.bitfocus.io/share/issue/7f2066b51654483dbe5cc68792c985c6/
Ok, what i meant by a more elegant way would be somthing like:
This could be done in a single reuseable function.
What IMHO could be a potential root cause is that remaining time becomes negative when mediaDuration is zero:
let timeRemaining = self.mediaSources[mediaSource.sourceName]['mediaDuration'] - data.timestamp
But IMHO the try catch would not be the right way to fix it.
I've already noticed that the mediaSources data structure is not persistant because it is always recreated when updating the values from obs. As the obs calls are async there is a time where the mediaSources object might be empty and if another part in the code relies on this values it would obviously find unexpected or no values. I've already tried to fix it in my remaining time feedback feature.
If you have a better solution then the try
- catch
bandaid method, I'm happy to review the PR when it comes through ;)
My proposal would be do the try-catch to workaround and I could have a look to that later when I find some time. But i would like to finish some other stuff before.
https://github.com/bitfocus/companion-module-obs-studio/blob/b5b65bc3c995d8071ff92b65a899eb2fef570ed0/index.js#L1022
This needs
try
-catch
similar to the others above it.new Date(timeRemaining).toISOString().slice(11, 19)
is the problem