@@ -39,6 +39,7 @@ import { MosDeviceConfig } from './generated/devices'
3939import { PeripheralDeviceForDevice } from '@sofie-automation/server-core-integration'
4040import _ = require( 'underscore' )
4141import { MosStatusHandler } from './mosStatusHandler'
42+ import { isPromise } from 'util/types'
4243
4344export interface MosConfig {
4445 self : IConnectionConfig
@@ -61,7 +62,7 @@ interface MosDeviceHandle {
6162 readonly deviceOptions : Readonly < MosDeviceConfig >
6263
6364 // Once connected, a core handler is setup
64- coreMosHandler ?: CoreMosDeviceHandler
65+ coreMosHandler ?: CoreMosDeviceHandler | Promise < CoreMosDeviceHandler >
6566
6667 // If writing back story/item status is enabled, the setup handler
6768 statusHandler ?: MosStatusHandler
@@ -288,10 +289,9 @@ export class MosHandler {
288289 return
289290 }
290291
291- // nocommit - this is a bit of a race condition, as the deviceEntry is updated via an await
292+ // This is either a promise, if a handler is currently being setup, or the handler itself
292293 if ( deviceEntry . coreMosHandler ) {
293294 this . _logger . error ( `Got connection for mosDevice "${ mosDevice . idPrimary } " which is already setup!` )
294- // nocommit - do anything else?
295295 return
296296 }
297297
@@ -444,7 +444,7 @@ export class MosHandler {
444444 private sendStatusOfAllMosDevices ( ) {
445445 // Send an update to Core of the status of all mos devices
446446 for ( const handler of this . _allMosDevices . values ( ) ) {
447- if ( handler . coreMosHandler ) {
447+ if ( handler . coreMosHandler && ! isPromise ( handler . coreMosHandler ) ) {
448448 handler . coreMosHandler . onMosConnectionChanged ( handler . mosDevice . getConnectionStatus ( ) )
449449 }
450450 }
0 commit comments