I don't think an AFJ 0.3.3 agent is fully aware its initialized, or that when shutdown() is called something does not realize its not initialized any longer. I also tried calling await agent?.wallet.close() before and after shutdown() but it has no effect. You can make the first warning go away by calling await agent?.mediationRecipient.stopMessagePickup() before shutdown but I think if one command initializes the wallet then one command should fully uninitialize it.
Copy the TypeScript at the end of this issue to a ts file;
LOG: will initialize agent
LOG: did initialize agent
LOG: will shutdown agent
LOG: did shutdown agent
WARN: Unable to open websocket connection to mediator {
"error": {
"name": "IndySdkError",
"message": "IndyError(WalletInvalidHandle): WalletInvalidHandle",
"stack": "IndySdkError: IndyError(WalletInvalidHandle): WalletInvalidHandle\n at IndyStorageService.getById (/work/node_modules/@aries-framework/core/src/storage/IndyStorageService.ts:240:34)\n at async RecipientApi.openMediationWebSocket (/work/node_modules/@aries-framework/core/src/modules/routing/RecipientApi.ts:130:24)\n at async RecipientApi.openWebSocketAndPickUp (/work/node_modules/@aries-framework/core/src/modules/routing/RecipientApi.ts:222:9)\n at async RecipientApi.initiateMessagePickup (/work/node_modules/@aries-framework/core/src/modules/routing/RecipientApi.ts:272:9)",
"cause": {
"name": "IndyError",
"stack": "IndyError: WalletInvalidHandle\n at Object.callback (/work/node_modules/@aries-framework/node/node_modules/indy-sdk/src/wrapIndyCallback.js:15:10)",
"message": "WalletInvalidHandle",
"indyCode": 200,
"indyName": "WalletInvalidHandle",
"indyCurrentErrorJson": null
}
}
}
WARN: Unable to re-open websocket connection to mediator {
"error": {
"name": "AriesFrameworkError",
"message": "Wallet has not been initialized yet. Make sure to await agent.initialize() before using the agent.",
"stack": "AriesFrameworkError: Wallet has not been initialized yet. Make sure to await agent.initialize() before using the agent.\n at IndyWallet.get handle [as handle] (/work/node_modules/@aries-framework/core/src/wallet/IndyWallet.ts:78:13)\n at IndyStorageService.getById (/work/node_modules/@aries-framework/core/src/storage/IndyStorageService.ts:226:29)\n at ConnectionRepository.getById (/work/node_modules/@aries-framework/core/src/storage/Repository.ts:81:32)\n at ConnectionService.getById (/work/node_modules/@aries-framework/core/src/modules/connections/services/ConnectionService.ts:558:38)\n at RecipientApi.openMediationWebSocket (/work/node_modules/@aries-framework/core/src/modules/routing/RecipientApi.ts:130:53)\n at Object.next (/work/node_modules/@aries-framework/core/src/modules/routing/RecipientApi.ts:212:26)\n at ConsumerObserver.next (/work/node_modules/@aries-framework/core/node_modules/rxjs/src/internal/Subscriber.ts:161:25)\n at SafeSubscriber.Subscriber._next (/work/node_modules/@aries-framework/core/node_modules/rxjs/src/internal/Subscriber.ts:119:22)\n at SafeSubscriber.Subscriber.next (/work/node_modules/@aries-framework/core/node_modules/rxjs/src/internal/Subscriber.ts:75:12)\n at /work/node_modules/@aries-framework/core/node_modules/rxjs/src/internal/operators/tap.ts:128:26"
}
}
I would expect shutdown to be a clean function call and not print Make sure to await agent.initialize() before using the agent. because the code below does call this.
This might not be the issue it appears to be. Looking here it seems like the warnings are being triggered by emitting an event via stop$.next(true) which throws an exception.
I don't think an AFJ 0.3.3 agent is fully aware its initialized, or that when
shutdown()
is called something does not realize its not initialized any longer. I also tried callingawait agent?.wallet.close()
before and aftershutdown()
but it has no effect. You can make the first warning go away by callingawait agent?.mediationRecipient.stopMessagePickup()
before shutdown but I think if one command initializes the wallet then one command should fully uninitialize it.ts
file;Will log the following output:
I would expect shutdown to be a clean function call and not print
Make sure to await agent.initialize() before using the agent.
because the code below does call this.-- exampel script below --