Make onMessage use promises in case of async calls