Skip to content

Commit 79c292a

Browse files
authored
prompts user to re-enter sessionId if session not found (#5549)
listens for server error messages with the error code ofr sessionId not found while waiting for a session. throws an error if the sessionId is not found
1 parent c7755c4 commit 79c292a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ironfish-cli/src/multisigBroker/errors.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ export class SessionDecryptionError extends MultisigClientError {
5757
super(message)
5858
}
5959
}
60+
61+
export class InvalidSessionError extends MultisigClientError {
62+
constructor(message: string) {
63+
super(message)
64+
}
65+
}

ironfish-cli/src/multisigBroker/sessionManagers/sessionManager.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
import { Assert, Logger, PromiseUtils } from '@ironfish/sdk'
55
import { ux } from '@oclif/core'
66
import { MultisigClient } from '../clients'
7-
import { SessionDecryptionError } from '../errors'
7+
import {
8+
InvalidSessionError,
9+
MultisigBrokerErrorCodes,
10+
SessionDecryptionError,
11+
} from '../errors'
812
import { MultisigBrokerUtils } from '../utils'
913

1014
export abstract class MultisigSessionManager {
@@ -104,10 +108,18 @@ export abstract class MultisigClientSessionManager extends MultisigSessionManage
104108
clientError = error
105109
})
106110

111+
this.client.onMultisigBrokerError.on((errorMessage) => {
112+
if (errorMessage.error.code === MultisigBrokerErrorCodes.SESSION_ID_NOT_FOUND) {
113+
clientError = new InvalidSessionError(errorMessage.error.message)
114+
}
115+
})
116+
107117
while (!confirmed) {
108118
if (clientError) {
109119
if (clientError instanceof SessionDecryptionError) {
110120
this.passphrase = null
121+
} else if (clientError instanceof InvalidSessionError) {
122+
this.sessionId = null
111123
}
112124
ux.action.stop()
113125
throw clientError

0 commit comments

Comments
 (0)