websocket: fix sync issues, pending open/error/close events will be fired when corresponding callback is set