Meteor client side env vars and async/await

Has anyone had any luck getting env vars to play nice with async/await?

myEnvVar = new Meteor.EnvironmentVariable()
async function thing() {
  return new Promise((resolve) => setTimeout(() => resolve(), 100))
}
async function fn() {
   console.log(myEnvVar.get()); // whatever
   await thing();
   console.log(myEnvVar.get()); // undefined
}

myEnvVar.withValue("whatever", () => {
   return Promise.resolve(fn());
});

I’ve tried a bunch of different options - so long as I use promises (.then chaining) it works great. But as soon as I introduce async await - it fails. I’m guessing that the patches meteor applies to promises don’t work with async/await :frowning:

1 Like