Skip to content

Commit

Permalink
display 'Unknown' for node alias if backend throws or needs >10s
Browse files Browse the repository at this point in the history
  • Loading branch information
myxmaster committed Jan 30, 2025
1 parent 8a09915 commit 98f221b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"general.experimental": "Experimental",
"general.defaultNodeNickname": "My Lightning Node",
"general.active": "Active",
"general.unknown": "Unkown",
"restart.title": "Restart required",
"restart.msg": "ZEUS has to be restarted before the new configuration is applied.",
"restart.msg1": "Would you like to restart now?",
Expand Down
11 changes: 10 additions & 1 deletion stores/ChannelsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,15 @@ export default class ChannelsStore {
@action
getNodeInfo = (pubkey: string) => {
this.loading = true;
return BackendUtils.getNodeInfo([pubkey])

const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => reject(new Error('Timeout')), 10000);
});

return Promise.race([
timeoutPromise,
BackendUtils.getNodeInfo([pubkey])
])
.then((data: any) => {
this.loading = false;
if (data?.node?.alias)
Expand All @@ -307,6 +315,7 @@ export default class ChannelsStore {
})
.catch(() => {
this.loading = false;
this.aliasMap.set(pubkey, localeString('general.unknown'));
});
};

Expand Down

0 comments on commit 98f221b

Please sign in to comment.