mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-12 21:52:57 +00:00
Fix an issue with reporting initial config using a stale target state
Change-type: patch
This commit is contained in:
parent
14b01b2009
commit
ffe3da6261
@ -440,10 +440,9 @@ export class APIBinder {
|
||||
);
|
||||
}
|
||||
|
||||
const targetConfigUnformatted = _.get(
|
||||
await TargetState.get(),
|
||||
'local.config',
|
||||
);
|
||||
// We force a fresh get to make sure we have the latest state
|
||||
// and can guarantee we don't clash with any already reported config
|
||||
const targetConfigUnformatted = (await TargetState.get())?.local?.config;
|
||||
if (targetConfigUnformatted == null) {
|
||||
throw new InternalInconsistencyError(
|
||||
'Attempt to report initial state with malformed target state',
|
||||
|
@ -164,12 +164,10 @@ const poll = async (
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the latest target state, attempting a fetch first if we do not already have one
|
||||
* Checks for target state changes and then returns the latest target state
|
||||
*/
|
||||
export const get = async (): Promise<TargetState> => {
|
||||
if (cache == null) {
|
||||
await update();
|
||||
}
|
||||
await update();
|
||||
return _.cloneDeep(cache.body);
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user