fix(FN-4929): finalize daemon typecheck fix and changeset
Fusion-Task-Id: FN-4929 Fusion-Task-Lineage: 557ef659-c835-47de-b30c-a8b03d66d8bf
This commit is contained in:
committed by
gsxdsm
parent
02eb9dc2f6
commit
8d9b893ea1
5
.changeset/fn-4929-daemon-typecheck-fix.md
Normal file
5
.changeset/fn-4929-daemon-typecheck-fix.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@runfusion/fusion": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix a daemon startup ordering regression by deferring the peer-exchange global-settings read until after the primary task store is created, resolving `TS2448`/`TS2454` typecheck failures in `packages/cli/src/commands/daemon.ts`.
|
||||||
@@ -439,19 +439,35 @@ export async function runDaemon(opts: DaemonOptions = {}) {
|
|||||||
|
|
||||||
const store = primaryEngine.getTaskStore();
|
const store = primaryEngine.getTaskStore();
|
||||||
|
|
||||||
|
const getGlobalSettingsStore = () => {
|
||||||
|
const candidate = store as { getGlobalSettingsStore?: () => { getSettings: () => Promise<unknown> } };
|
||||||
|
return typeof candidate.getGlobalSettingsStore === "function"
|
||||||
|
? candidate.getGlobalSettingsStore()
|
||||||
|
: null;
|
||||||
|
};
|
||||||
|
|
||||||
if (peerExchangeService) {
|
if (peerExchangeService) {
|
||||||
void store.getGlobalSettingsStore().getSettings().then((globalSettings) => {
|
const globalSettingsStore = getGlobalSettingsStore();
|
||||||
peerExchangeService?.updateGlobalSettings(globalSettings);
|
if (globalSettingsStore) {
|
||||||
}).catch((err) => {
|
void globalSettingsStore.getSettings().then((globalSettings) => {
|
||||||
const message = err instanceof Error ? err.message : String(err);
|
peerExchangeService?.updateGlobalSettings(
|
||||||
console.warn(`[daemon] Failed to load initial peer exchange settings: ${message}`);
|
globalSettings as Parameters<PeerExchangeService["updateGlobalSettings"]>[0],
|
||||||
});
|
);
|
||||||
|
}).catch((err) => {
|
||||||
|
const message = err instanceof Error ? err.message : String(err);
|
||||||
|
console.warn(`[daemon] Failed to load initial peer exchange settings: ${message}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
store.on("settings:updated", () => {
|
store.on("settings:updated", () => {
|
||||||
if (!peerExchangeService) return;
|
if (!peerExchangeService) return;
|
||||||
void store.getGlobalSettingsStore().getSettings().then((globalSettings) => {
|
const globalSettingsStore = getGlobalSettingsStore();
|
||||||
peerExchangeService?.updateGlobalSettings(globalSettings);
|
if (!globalSettingsStore) return;
|
||||||
|
void globalSettingsStore.getSettings().then((globalSettings) => {
|
||||||
|
peerExchangeService?.updateGlobalSettings(
|
||||||
|
globalSettings as Parameters<PeerExchangeService["updateGlobalSettings"]>[0],
|
||||||
|
);
|
||||||
}).catch(() => undefined);
|
}).catch(() => undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user