Prevent BLE HR monitor process crash (fixes: #135)

In case of an uncaught exception in the BLE HR child process the process
would crash and not restart. Add code to catch these uncaught exceptions
to prevent such crash and enable code to continue.
This commit is contained in:
Abász 2023-03-25 19:43:26 +01:00
parent c5bec08ea9
commit ee667d727a
1 changed files with 12 additions and 4 deletions

View File

@ -11,7 +11,15 @@ import config from '../../../tools/ConfigManager.js'
import { createHeartRateManager } from './HeartRateManager.js'
log.setLevel(config.loglevel.default)
const heartRateManager = createHeartRateManager()
heartRateManager.on('heartRateMeasurement', (heartRateMeasurement) => {
process.send(heartRateMeasurement)
})
start()
function start () {
const heartRateManager = createHeartRateManager()
heartRateManager.on('heartRateMeasurement', (heartRateMeasurement) => {
process.send(heartRateMeasurement)
})
process.on('uncaughtException', (err) => {
log.error('An error occurred in BLE Heart Rate service if you experience issues with the bluetooth connection to your heart rate sensor please restart app: ', err)
})
}