Comm not working after refreshing page in browser

I have a small extension which uses comms api.
from the front end I register the comm using registerCommTarget
everything is working fine until I refresh the browser.

The problem is the message handler is added as a callback to the function calling registerCommTarget. If we refresh the page this piece of code never gets invoked.
Could someone point me in the right direction

this.kernel?.registerCommTarget(commTarget, (comm, _) => {
    comm.onMsg = (message) => {
        this.handleMessage(message);
    };
});

in the older codebase there use to be one method called connectToComm