Skip to content

Commit d99e8b2

Browse files
fix(lit-node-client-nodejs): LIT-4016 - Throw an error if we are iterating across this.connectedNodes to build sessionSigs, but the client is disconnected - the sessionSigs map could be incomplete in this case
1 parent bb21608 commit d99e8b2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,18 @@ export class LitNodeClientNodeJs
22032203

22042204
const signatures: SessionSigsMap = {};
22052205

2206+
if (!this.ready) {
2207+
// If the client isn't ready, `connectedNodes` may be out-of-date, and we should throw an error immediately
2208+
const message =
2209+
'[executeJs] LitNodeClient is not ready. Please call await litNodeClient.connect() first.';
2210+
2211+
throwError({
2212+
message,
2213+
errorKind: LIT_ERROR.LIT_NODE_CLIENT_NOT_READY_ERROR.kind,
2214+
errorCode: LIT_ERROR.LIT_NODE_CLIENT_NOT_READY_ERROR.name,
2215+
});
2216+
}
2217+
22062218
this.connectedNodes.forEach((nodeAddress: string) => {
22072219
const toSign: SessionSigningTemplate = {
22082220
...signingTemplate,

0 commit comments

Comments
 (0)