Better forge
This commit is contained in:
parent
956fa6dcff
commit
ed3bab0f8e
1 changed files with 27 additions and 14 deletions
|
|
@ -240,7 +240,7 @@ const isReady = () =>
|
||||||
|
|
||||||
let procID = 0
|
let procID = 0
|
||||||
|
|
||||||
const forge = () => {
|
const forge = async () => {
|
||||||
logger.info(`Forging Gun # ${++procID}`)
|
logger.info(`Forging Gun # ${++procID}`)
|
||||||
if (isForging) {
|
if (isForging) {
|
||||||
throw new Error('Double forge?')
|
throw new Error('Double forge?')
|
||||||
|
|
@ -274,8 +274,18 @@ const forge = () => {
|
||||||
opts: lastOpts,
|
opts: lastOpts,
|
||||||
type: 'init'
|
type: 'init'
|
||||||
}
|
}
|
||||||
|
await new Promise(res => {
|
||||||
|
currentGun.on('message', msg => {
|
||||||
|
if (msg.type === 'init') {
|
||||||
|
// @ts-ignore
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
})
|
||||||
currentGun.send(initMsg)
|
currentGun.send(initMsg)
|
||||||
logger.info('Sent init msg')
|
logger.info('Sent init msg')
|
||||||
|
})
|
||||||
|
|
||||||
|
logger.info('Received init reply')
|
||||||
|
|
||||||
const lastGunListeners = Object.keys(pathToListeners).map(path => {
|
const lastGunListeners = Object.keys(pathToListeners).map(path => {
|
||||||
/** @type {Smith.SmithMsgOn} */
|
/** @type {Smith.SmithMsgOn} */
|
||||||
|
|
@ -309,17 +319,20 @@ const forge = () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isReforge) {
|
logger.info(
|
||||||
logger.info('Finished reforging, will now auto-auth')
|
isReforge
|
||||||
autoAuth().then(() => {
|
? 'Finished reforging, will now auto-auth'
|
||||||
|
: 'Finished forging, will now auto-auth'
|
||||||
|
)
|
||||||
|
|
||||||
|
await autoAuth()
|
||||||
|
|
||||||
|
// Eslint disable: This should be caught by a if (isForging) {throw} at the
|
||||||
|
// beginning of this function
|
||||||
|
|
||||||
|
// eslint-disable-next-line require-atomic-updates
|
||||||
isForging = false
|
isForging = false
|
||||||
flushPendingPuts()
|
flushPendingPuts()
|
||||||
})
|
|
||||||
} else {
|
|
||||||
logger.info('Finished forging, will now auto-auth')
|
|
||||||
isForging = false
|
|
||||||
flushPendingPuts()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue