-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Top-level await does not seem to work in Meteor 3 #12986
Comments
@zodern maybe you can shed some light here? what am I doing wrong? |
hmm, we have a similar problem, with Meteor 3 beta 4
Roles here is undefined. |
Any update here? |
New simpler repro repo: https://github.com/perbergland/tla-repro/tree/main The produced reified code for tla-file.js does NOT look correct. It differs from the example in the reify readme file since it is not marked as async: true /////////////////////////////////////////////////////////////////////////////////////////////
// //
// server/tla-file.js //
// //
/////////////////////////////////////////////////////////////////////////////////////////////
//
!module.wrapAsync(async function (module1, __reifyWaitForDeps__, __reify_async_result__) {
"use strict";
try {
module1.export({
tlaValue: () => tlaValue,
someFunction: () => someFunction
});
let axios;
module1.link("axios", {
default(v) {
axios = v;
}
}, 0);
if (__reifyWaitForDeps__()) (await __reifyWaitForDeps__())();
const asyncMethod = async () => {
return 4;
};
console.log("before tla init");
const tlaValue = await asyncMethod();
console.log("after tla init");
const someFunction = () => {
return 7;
};
__reify_async_result__();
} catch (_reifyError) {
return __reify_async_result__(_reifyError);
}
__reify_async_result__()
}, {
self: this,
async: false
});
`` |
This is a bug in https://github.com/meteor/reify - it does not handle the case where the await is in the right hand side of a top level assignment, e.g.
I would rate this as a top level priority to fix for Meteor 3 Workaround:
anywhere in the file |
The code to fix (along with a new test case) is: |
Thanks to @zodern for the pointer to the reify code that needs fixing |
I am taking a look at the fix here and checking if I can expand on that to cover a wider range of cases. |
This was fixed here, forgot to link the issue I think |
Is this believed to be fixed in 3.0.1? I'm still having this issue in a test that imports a top-level-await module, but at least the workaround of awaiting without assigning the result works for me. |
I can confirm that this is NOT working in meteor 3.0.1 but I cannot figure out why. The workaround is still needed. Filing an issue in the meteor/reify repo |
I've tested this with the PR #13298, and it worked as expected. After the tests pass, we will merge it, and it will be included in version 3.0.4. |
Given I have a file with the following contents:
And then I import it:
Expected behaviour
json data from the response is logged
Actual behaviour
The output is
imported { [Symbol(__esModule)]: true }
.In Meteor 2, everything works. Repo with repro - https://github.com/alisnic/meteor3-tla-repro (do a npm start to see the log).
meteor/packages
The text was updated successfully, but these errors were encountered: