Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(keys): use Promise.allSettled to handle corrupted keypair files
Replace Promise.all() with Promise.allSettled() so that a single
corrupted or unreadable keypair file no longer crashes the entire
keys list command. Valid keys are still displayed, and a warning
is logged for any that failed to load.

Fixes #23
  • Loading branch information
NathanOyewole committed Oct 28, 2026
commit 3cd28f6e05f067e830b10615c2472338519355f0
13 changes: 12 additions & 1 deletion src/commands/KeysCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class KeysCommand {
);
const keychainFiles = files.filter((f) => f.endsWith(".keychain.json"));

const keypairData = await Promise.all(
const keypairResults = await Promise.allSettled(
keypairFiles.map(async (file) => {
const name = file.replace(".json", "");
const signer = await Signer.load(name);
Expand All @@ -139,6 +139,17 @@ export class KeysCommand {
})
);

const keypairData = keypairResults
.map((result, index) => {
if (result.status === "fulfilled") {
return result.value;
}
const name = keypairFiles[index]?.replace(".json", "") ?? "unknown";
console.warn(`Warning: Failed to load keypair "${name}": ${result.reason}`);
return null;
})
.filter((item): item is NonNullable<typeof item> => item !== null);

const keychainData = keychainFiles.map((file) => {
const name = file.replace(".keychain.json", "");
const config = KeychainConfig.load(name);
Expand Down