gun subprocess now checks its death

This commit is contained in:
Daniel Lugo 2021-09-16 17:11:16 -04:00
parent 6d2ebbcc36
commit 7c142aa4dd

View file

@ -65,10 +65,21 @@ const waitForAuth = async () => {
return waitForAuth() return waitForAuth()
} }
let dead = false
/** /**
* @param {Smith.SmithMsg} msg * @param {Smith.SmithMsg} msg
*/ */
const handleMsg = async msg => { const handleMsg = async msg => {
if (dead) {
logger.error('Dead sub-process received msg: ', msg)
return
}
// @ts-ignore
if (msg === 'bye') {
logger.info('KILLING')
dead = true
}
if (Array.isArray(msg)) { if (Array.isArray(msg)) {
msg.forEach(handleMsg) msg.forEach(handleMsg)
return return