fix: keep status read-only while gateway owns state (#124142)

This commit is contained in:
Josh Lehman
2026-08-15 07:21:19 -07:00
committed by GitHub
parent c00dd282db
commit 9663cc7edc
18 changed files with 259 additions and 58 deletions
+15 -1
View File
@@ -9,6 +9,7 @@ import {
executeSqliteQueryTakeFirstSync,
getNodeSqliteKysely,
} from "../infra/kysely-sync.js";
import { withExistingOpenClawStateDatabaseReadOnly } from "../state/openclaw-state-db-readonly.js";
import type { DB as OpenClawStateKyselyDatabase } from "../state/openclaw-state-db.generated.js";
import {
openOpenClawStateDatabase,
@@ -175,7 +176,7 @@ function configToRow(params: {
}
function readNodeHostConfigRow(
database: ReturnType<typeof openOpenClawStateDatabase>,
database: Pick<ReturnType<typeof openOpenClawStateDatabase>, "db">,
): NodeHostConfigRuntimeRow | undefined {
return executeSqliteQueryTakeFirstSync(
database.db,
@@ -208,6 +209,19 @@ export async function loadNodeHostConfig(
return row ? rowToNodeHostConfig(row) : null;
}
/** Load existing node-host state without creating or joining the writable shared-state lifecycle. */
export async function loadNodeHostConfigReadOnly(
env: NodeJS.ProcessEnv = process.env,
): Promise<NodeHostConfig | null> {
assertNodeHostLegacyStateMigrated(env);
return (
withExistingOpenClawStateDatabaseReadOnly(({ db }) => {
const row = readNodeHostConfigRow({ db });
return row ? rowToNodeHostConfig(row) : null;
}, databaseOptions(env)) ?? null
);
}
/**
* Atomically create or replace the complete node-host snapshot.
* Candidate facts are prepared before BEGIN; the transaction rereads the authoritative row.