mirror of
https://fastgit.cc/github.com/openclaw/openclaw
synced 2026-05-01 06:36:23 +08:00
perf(config): skip cold runtime refresh on one-shot writes
This commit is contained in:
@@ -199,7 +199,10 @@ describe("resolveGatewayInstallToken", () => {
|
||||
},
|
||||
},
|
||||
}),
|
||||
expect.objectContaining({ baseSnapshot: expect.any(Object) }),
|
||||
expect.objectContaining({
|
||||
baseSnapshot: expect.any(Object),
|
||||
skipRuntimeSnapshotRefresh: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ async function maybePersistAutoGeneratedGatewayInstallToken(params: {
|
||||
baseSnapshot: snapshot,
|
||||
...prepared.writeOptions,
|
||||
...params.configWriteOptions,
|
||||
skipRuntimeSnapshotRefresh: true,
|
||||
},
|
||||
);
|
||||
return params.token;
|
||||
|
||||
@@ -79,6 +79,7 @@ import {
|
||||
registerRuntimeConfigWriteListener,
|
||||
resetConfigRuntimeState as resetConfigRuntimeStateState,
|
||||
setRuntimeConfigSnapshot as setRuntimeConfigSnapshotState,
|
||||
getRuntimeConfigSnapshotRefreshHandler as getRuntimeConfigSnapshotRefreshHandlerState,
|
||||
setRuntimeConfigSnapshotRefreshHandler as setRuntimeConfigSnapshotRefreshHandlerState,
|
||||
type RuntimeConfigWriteNotification,
|
||||
} from "./runtime-snapshot.js";
|
||||
@@ -154,6 +155,11 @@ export type ConfigWriteOptions = {
|
||||
* Avoids rereading the full config just to prepare an immediate write.
|
||||
*/
|
||||
baseSnapshot?: ConfigFileSnapshot;
|
||||
/**
|
||||
* Internal one-shot CLI fast path. When no runtime snapshot is active, skip
|
||||
* the post-write runtime snapshot refresh/reload tail entirely.
|
||||
*/
|
||||
skipRuntimeSnapshotRefresh?: boolean;
|
||||
};
|
||||
|
||||
export type ReadConfigFileSnapshotForWriteResult = {
|
||||
@@ -1799,7 +1805,15 @@ export async function writeConfigFile(
|
||||
envSnapshotForRestore: options.envSnapshotForRestore,
|
||||
}),
|
||||
unsetPaths: options.unsetPaths,
|
||||
skipRuntimeSnapshotRefresh: options.skipRuntimeSnapshotRefresh,
|
||||
});
|
||||
if (
|
||||
options.skipRuntimeSnapshotRefresh &&
|
||||
!hadRuntimeSnapshot &&
|
||||
!getRuntimeConfigSnapshotRefreshHandlerState()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const notifyCommittedWrite = () => {
|
||||
const currentRuntimeConfig = getRuntimeConfigSnapshotState();
|
||||
if (!currentRuntimeConfig) {
|
||||
|
||||
Reference in New Issue
Block a user