jlcodes99/cockpit-tools · warning
[AntigravityRuntime] failed to resolve preferred target:
Error message
[AntigravityRuntime] failed to resolve preferred target:
What it means
The useAntigravityRuntimeTarget hook (src/hooks/useAntigravityRuntimeTarget.ts:57) resolves the user's preferred Antigravity runtime target on mount. If the async resolution promise rejects, the .catch logs a console.warn '[AntigravityRuntime] failed to resolve preferred target:' with the error and leaves the target at its initial value. It is a non-fatal warning: the UI keeps the default target instead of the preference.
Source
Thrown at src/hooks/useAntigravityRuntimeTarget.ts:57
useEffect(() => {
if (antigravityRuntimeTargetAutoResolveStarted) {
return;
}
antigravityRuntimeTargetAutoResolveStarted = true;
const initialTarget = getAntigravityRuntimeTarget();
void resolvePreferredAntigravityRuntimeTarget(initialTarget)
.then((preferredTarget) => {
if (preferredTarget === initialTarget) {
return;
}
if (getAntigravityRuntimeTarget() !== initialTarget) {
return;
}
setAntigravityRuntimeTarget(preferredTarget);
})
.catch((error) => {
console.warn('[AntigravityRuntime] failed to resolve preferred target:', error);
});
}, []);
return target;
}
View on GitHub (pinned to 1ed8b77992)
Solutions
- Read the logged error object to see the underlying cause (invoke name, backend message).
- Retry the resolution (e.g. re-mount the component or re-run the effect) once the backend is ready.
- Reset the runtime target preference to the default if the saved one references a missing runtime.
- Verify the app runs inside the Tauri shell — in a plain browser build the backend command will always fail.
Example fix
// before
.catch((error) => {
console.warn('[AntigravityRuntime] failed to resolve preferred target:', error);
});
// after
.catch((error) => {
console.warn('[AntigravityRuntime] failed to resolve preferred target:', error);
setAntigravityRuntimeTarget(initialTarget); // explicit fallback
}); Defensive patterns
Strategy: fallback
Validate before calling
// Before trusting the preference:
const preferred = localStorage.getItem('antigravityRuntimeTarget');
const valid = preferred == null || ['stable', 'insiders'].includes(preferred);
if (!valid) localStorage.removeItem('antigravityRuntimeTarget'); Type guard
function isRuntimeTarget(v: unknown): v is RuntimeTarget {
return v === 'stable' || v === 'insiders';
} Try / catch
getAntigravityRuntimeTarget()
.then(setAntigravityRuntimeTarget)
.catch((error) => {
console.warn('[AntigravityRuntime] failed to resolve preferred target:', error);
setAntigravityRuntimeTarget(initialTarget);
}); Prevention
- Reset runtime target preferences after uninstalling/reinstalling Antigravity.
- Only invoke backend commands inside the Tauri shell; guard isTauri() in web builds.
- Delay preference resolution until backend services report ready.
When it happens
Trigger: On component mount, the backend command backing getAntigravityRuntimeTarget()/preference resolution rejects — e.g. Tauri invoke failure, backend not ready yet, or persisted preference referencing a missing runtime — and the promise rejects before setAntigravityRuntimeTarget runs.
Common situations: App started before the backend service initialized; saved runtime preference points at an uninstalled Antigravity version; web (non-Tauri) build where invoke is unavailable; transient IPC error.
Related errors
- [AntigravityRuntime] failed to detect ${target} ${scanMode}
- [WebDAV] Auto backup upload failed
- [CodexExport] get downloads dir failed:
- [AccountGroups] Failed to load groups: ${String(error)}
- Claude login start 响应缺少关键字段
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/cf5404ac72487edb.
Report an issue: GitHub.