jely2002/youtube-dl-gui · error · Error
Failed to initialize stronghold
Error message
Failed to initialize stronghold: ${initStatus.initError} What it means
initialize invokes 'stronghold_init' in the Rust backend to create/unlock the stronghold. If the returned payload carries initError, the store stores it, marks the vault unlocked=false, and throws 'Failed to initialize stronghold: ${initError}'. It prevents treating a failed init as a usable vault.
Solutions
- Surface status.value.initError to the user; for password errors prompt to retry with the correct password.
- If the snapshot is corrupt, move/delete it and call initialize again to create a fresh vault.
- Check that the app's data directory is writable and the disk is not full.
- Catch the error in the UI and show a recovery flow rather than an unhandled rejection.
Example fix
// before
await strongholdStore.initialize();
// after
try {
await strongholdStore.initialize();
} catch {
showError(strongholdStore.status.initError); // e.g. wrong password
} Defensive patterns
Strategy: try-catch
Validate before calling
if (!password || password.length === 0) {
throw new Error('Password required to initialize stronghold');
} Type guard
const initSucceeded = (s: StrongholdInitPayload): boolean => !s.initError;
Try / catch
try {
await strongholdStore.initialize();
} catch (e) {
if (e instanceof Error && e.message.startsWith('Failed to initialize stronghold')) {
promptRetryPassword(); // most common cause: wrong password
return;
}
throw e;
} Prevention
- Validate the password is present and meets rules before calling initialize.
- Never hard-kill the app during a snapshot write; flush before exit.
- Ensure the data directory is writable and migrate snapshots across app version upgrades.
When it happens
Trigger: invoke('stronghold_init') responds with initError — bad password on unlock attempt, snapshot corruption, disk/permission problems writing the snapshot, or an incompatible stronghold version on the backend.
Common situations: User enters the wrong vault password; the app was killed mid-write leaving a truncated snapshot; read-only install directory or sandbox blocking snapshot writes; upgrading the app across an incompatible stronghold format.
Related errors
AI-assisted analysis of jely2002/youtube-dl-gui@c402ee39c0 (2026-09-12).
Data as JSON: /api/errors/11d0b08f51aa84d9.
Report an issue: GitHub.
Appendix: source
Thrown at src/stores/stronghold.ts:57
status.value.unlocked = true;
availableKeys.value = await invoke('stronghold_keys');
} else if (!strongholdStatus.unlocked && !strongholdStatus.initError) {
status.value.unlocked = false;
} else {
status.value.unlocked = false;
status.value.initError = strongholdStatus.initError ?? 'Unknown error.';
throw new Error(`Failed to retrieve stronghold status: ${strongholdStatus.initError}`);
}
return status.value;
}
async function initialize(): Promise<StrongholdStatus> {
const initStatus: StrongholdInitPayload = await invoke('stronghold_init');
if (initStatus.initError) {
status.value.initError = initStatus.initError;
status.value.unlocked = false;
throw new Error(`Failed to initialize stronghold: ${initStatus.initError}`);
}
status.value.unlocked = initStatus.unlocked;
availableKeys.value = await invoke('stronghold_keys');
return status.value;
}
async function getValues(): Promise<StrongholdFields> {
const keys = Object.values(STRONGHOLD_KEYS);
const entries = await invoke<Record<string, number[] | null>>('stronghold_get', { keys });
const decoder = new TextDecoder();
const result = {} as StrongholdFields;
for (const [field, path] of Object.entries(STRONGHOLD_KEYS)) {
const raw = entries[path];
if (raw == null) {
result[field as keyof StrongholdFields] = null;
} else {View on GitHub (pinned to c402ee39c0)