beekeeper | Notification about closing wallet is sent multiple times

FYI: @kmochocki @Trela

As the title says, beekeeper looks to be sending a notification about closing wallets multiple times, after actually closing such a wallet.

Path to reproduce looks like:

  1. Launch clive
  2. Activate with timeout=60s and just wait
  3. Clive deactivates after 1min because of beekeeper notification
  4. Clive gets another notification about wallets closing after ~14mins since activation

Beekeeper log:

2512119ms json_rpc_plugin.cpp:222       initialize           ] initializing JSON RPC plugin
2512119ms webserver_plugin.cpp:584      plugin_initialize    ] initializing webserver plugin
2512119ms webserver_plugin.cpp:587      plugin_initialize    ] configured with 1 thread pool size
2512119ms webserver_plugin.cpp:590      plugin_initialize    ] Compression in webserver is disabled
2512119ms webserver_plugin.cpp:602      plugin_initialize    ] configured http to listen on 0.0.0.0:0
2512119ms beekeeper_app_init.cpp:120    initialize_program_o ] initializing options
2512119ms notifications.cpp:64          setup                ] setting up notification handler for 1 address
2512120ms beekeeper_app_init.cpp:157    initialize_program_o ] Backtrace on segfault is enabled.
2512120ms webserver_plugin.cpp:290      operator()           ] start processing http thread
2512120ms webserver_plugin.cpp:305      operator()           ] start listening for http requests on 0.0.0.0:44735
2517125ms json_rpc_plugin.cpp:439       rpc                  ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.create_session","params":{"notifications_endpoint":"127.0.0.1:44721",    "salt":"140203550380032"}}
2524518ms json_rpc_plugin.cpp:439       rpc                  ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.open","params":{"wallet_name":"alice","token":"963fe1f463076c55fc55df    aac99be158b8b91fc25610e33040cf9b3031317dac"}}
2524520ms json_rpc_plugin.cpp:439       rpc                  ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.unlock","params":{"wallet_name":"alice","password":"alice","token":"9    63fe1f463076c55fc55dfaac99be158b8b91fc25610e33040cf9b3031317dac"}}
2524523ms json_rpc_plugin.cpp:439       rpc                  ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.set_timeout","params":{"seconds":60,"token":"963fe1f463076c55fc55dfaa    c99be158b8b91fc25610e33040cf9b3031317dac"}}
3553016ms json_rpc_plugin.cpp:439       rpc                  ] message: {"id":0,"jsonrpc":"2.0","method":"beekeeper_api.close_session","params":{"token":"963fe1f463076c55fc55dfaac99be158b8b    91fc25610e33040cf9b3031317dac"}}
3553018ms application.cpp:99            handle_signal        ] _last_signal_code: 2
3553018ms application.cpp:90            generate_interrupt_r ] interrupt requested!
3553018ms webserver_plugin.cpp:651      plugin_pre_shutdown  ] Shutting down webserver_plugin...
3553018ms webserver_plugin.cpp:310      operator()           ] http io service exit
3553018ms application.cpp:473           finish               ] Waiting for logging_thread quit
3553018ms application.cpp:475           finish               ] logging_thread quit done

Clive log:

2023-08-22 14:42:04.516 | ℹ️ INFO     | clive.__private.core.commands.abc.command:_log_execution_info:40 - Executing command: Activate
2023-08-22 14:42:04.522 | ℹ️ INFO     | clive.__private.core.commands.abc.command:_log_execution_info:40 - Executing command: SetTimeout
2023-08-22 14:42:04.524 | ℹ️ INFO     | clive.__private.core.commands.set_timeout:_execute:20 - Timeout set to 60 s.                                   
2023-08-22 14:42:04.525 | ℹ️ INFO     | clive.__private.core.app_state:activate:33 - Mode switched to ACTIVE.

2023-08-22 14:43:04.558 | ℹ️ INFO     | clive.__private.core.beekeeper.notifications:notify:32 - Got notification: {'value': {}, 'time': '2023-08-22T12      :43:04', 'name': 'Attempt of closing all wallets'}                                                                                                    
2023-08-22 14:43:04.559 | 🐞 DEBUG    | clive.__private.core.beekeeper.notifications:__notify_listeners_about_wallets_closing:71 - Notifying listeners       about wallets closing                                                                                                                                
2023-08-22 14:43:04.559 | ℹ️ INFO     | clive.__private.core.app_state:deactivate:37 - Mode switched to INACTIVE.

2023-08-22 14:56:52.152 | ℹ️ INFO     | clive.__private.core.beekeeper.notifications:notify:32 - Got notification: {'value': {}, 'time': '2023-08-22T12      :56:52', 'name': 'Attempt of closing all wallets'}                                                                                                    
2023-08-22 14:56:52.153 | 🐞 DEBUG    | clive.__private.core.beekeeper.notifications:__notify_listeners_about_wallets_closing:71 - Notifying listeners       about wallets closing                                                                                                                                
2023-08-22 14:56:52.153 | ℹ️ INFO     | clive.__private.core.app_state:deactivate:37 - Mode switched to INACTIVE.

Full logs: stderr.log 2023-08-22_14-41-51_debug.log

Edited by Mateusz Żebrak