From b86c74276aad18601933416b45ac5f880f24d8e3 Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 21 Oct 2026 15:02:15 +0200 Subject: [PATCH] fix(owner): stop cli.execute from waiting on its own entry module With no server running, the CLI becomes the store owner itself and cli.execute imports ../cli.js. That module is the entry point and is still inside its top-level await main(), so the import resolves only after main() returns: every live command waited out its timeout with UNKNOWN_RESULT. cli.js now hands its handler to owner-operations before main() runs. Co-Authored-By: Claude Opus 5.5 (1M context) --- cli.js | 4 +++- core/owner-operations.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cli.js b/cli.js index a31b2fa..4ec37a8 100755 --- a/cli.js +++ b/cli.js @@ -32,7 +32,7 @@ import { createTelegramClient as createTelegramClientBase, } from './core/services.js'; import { ArchiveReader } from './core/archive-reader.js'; -import { runOwnerOperation } from './core/owner-operations.js'; +import { registerCliModule, runOwnerOperation } from './core/owner-operations.js'; import { createOwnerOperations } from './core/owner-operations.js'; import { callOwner, startOwnerIpc } from './core/owner-ipc.js'; import { startShutdownWatchdog } from './core/shutdown.js'; @@ -4838,6 +4838,8 @@ export { writeError, }; +registerCliModule({ executeOwnerCliCommand }); + if (isCliEntrypoint()) { await main(); } diff --git a/core/owner-operations.js b/core/owner-operations.js index d598bb0..1285324 100644 --- a/core/owner-operations.js +++ b/core/owner-operations.js @@ -6,6 +6,9 @@ import { OwnerCoordinator } from './owner-coordinator.js'; import { acquireOwnerLock, isPidAlive, parseStoreLock, readStoreLock } from '../store-lock.js'; let cliModulePromise; +export function registerCliModule(cliModule) { + cliModulePromise = Promise.resolve(cliModule); +} function loadCliModule() { cliModulePromise ??= import('../cli.js').catch((error) => { cliModulePromise = null;