How to handel async code inside Meteor.js Accounts.registerLoginHandler

Hi, i am registering a custom login Handler for OTP based authentication.

Accounts.registerLoginHandler(async function(loginRequest){
    if (!loginRequest.sms) return;
    let user = await handelLogin(loginRequest);
    console.log(user);
    return user;
});

In above code handelLogin(loginRequest) is asynchronous function and returns {userId:'.....'} after doing a network request and verifying OTP code.
When called this login handler from client i am getting this error

Exception while invoking method 'login' Error: A login method must specify a userId or an error

with some googling i found i need to wait for user variable to have value and then return it, so i used async and await in above code.But still getting same error.

After this ‘login’ Error this console.log(user); from above code is logged on server console after some time.

So why its not returning user ? So any suggestions or another way to achieve this.

Did you ever get a workaround for this?

This won’t work because async functions return promise, however login handlers are expected to return user object.
The solution/workaround is use Meteor.wrapAsync().