mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-22 18:35:21 -06:00
fix: keep status read-only while gateway owns state (#124142)
This commit is contained in:
+15
-1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user