diff --git a/packages/common-db/src/lib/common/tools.ts b/packages/common-db/src/lib/common/tools.ts index ad2e96ece3..678de55bf9 100644 --- a/packages/common-db/src/lib/common/tools.ts +++ b/packages/common-db/src/lib/common/tools.ts @@ -2640,7 +2640,7 @@ export function decrypt(key: string, value: string): string { * @param it The variable to test * @returns true if it is Record */ -export function isObject(it: any): it is Record { +export function isObject(it: unknown): it is Record { // This is necessary because: // typeof null === 'object' // typeof [] === 'object' @@ -2654,8 +2654,8 @@ export function isObject(it: any): it is Record { * * @param it The variable to test */ -export function isArray(it: any): it is any[] { - return Array.isArray(it); // from node 0.1 is a part of engine +export function isArray(it: unknown): it is any[] { + return Array.isArray(it); } /** diff --git a/packages/controller/src/main.ts b/packages/controller/src/main.ts index e3f81d0065..81851fc181 100644 --- a/packages/controller/src/main.ts +++ b/packages/controller/src/main.ts @@ -138,6 +138,13 @@ interface RepoRequester { callback: ioBroker.MessageCallbackInfo; } +interface SendResponseToOptions { + /** The message we want to respond to */ + receivedMsg: ioBroker.SendableMessage; + /** The response payload */ + payload: Record; +} + /** Host information including host id and running version */ type HostInformation = ioBroker.HostCommon & { host: string; runningVersion: string }; @@ -272,7 +279,7 @@ function getConfig(): ioBroker.IoBrokerJson | never { * @param _config * @param secret */ -async function _startMultihost(_config: Record, secret: string | false): Promise { +async function _startMultihost(_config: ioBroker.IoBrokerJson, secret: string | false): Promise { const MHService = await import('./lib/multihostServer.js'); const cpus = os.cpus(); mhService = new MHService.MHServer( @@ -297,7 +304,7 @@ async function _startMultihost(_config: Record, secret: string | fa * * @param __config - the iobroker config object */ -async function startMultihost(__config?: Record): Promise { +async function startMultihost(__config?: ioBroker.IoBrokerJson): Promise { if (compactGroupController) { return; } @@ -341,7 +348,7 @@ async function startMultihost(__config?: Record): Promise 30_000) // prevent sending of diagnostics by multiple admin instances ) { @@ -2849,9 +2855,8 @@ async function processMessage(msg: ioBroker.SendableMessage): Promise stat.mtimeMs }, msg.callback); } catch { const error = `Cannot parse file ${configFile}`; @@ -2871,56 +2876,58 @@ async function processMessage(msg: ioBroker.SendableMessage): Promise { + const { receivedMsg, payload } = options; + + if (receivedMsg.callback && receivedMsg.from) { + await sendTo(receivedMsg.from, receivedMsg.command, payload, receivedMsg.callback); + } +} + /** * Collect all instances on this host and call `initInstances` */ @@ -5242,7 +5262,7 @@ export async function init(compactGroupId?: number): Promise { stopTimeout += 5_000; } - // If bootstrap file detected, it must be deleted, but give time for a bootstrap process to use this file + // If a bootstrap file detected, it must be deleted, but give time for a bootstrap process to use this file if (fs.existsSync(VENDOR_BOOTSTRAP_FILE)) { setTimeout(() => { try {