Top level await does not work in Meteor 3 rc0

I tried to update an app and stumbled on the same problem that was reported here.

There have been no comments since February - is TLA still targeted to work properly in Meteor 3?

1 Like

From the Git discussion.

import axios from "axios";

const getAndrei = async () => {
  const response = await axios.get('https://api.github.com/users/alisnic')
  return response.data
};

const Andrei = await getAndrei();

export default Andrei;

Something doesn’t look right or … elegant to say the least. Why not export the function instead of exporting the results?

Created a super simple repro case: GitHub - perbergland/tla-repro: Repro for meteor 3 rc0 top-level await problem

This is the output

=> Started proxy.                             
=> Started MongoDB.                           
I20240503-13:02:00.302(2)? before tla init    
I20240503-13:02:00.306(2)? after tla init
I20240503-13:02:00.306(2)? Starting!
I20240503-13:02:00.306(2)? { tlaValue: undefined, someFunction: undefined }

To me this is very surprising behaviour. I expected TLA to be transparent and that reify would automatically await all imports before continuing loading modules.

That is, this is what I expected:

{ tlaValue: 4, someFunction: (the function code) }

I have added more info to the github issue and got more details from zodern.
A workaround is to add await 0 anywhere in the file that is imported.