leonardoventurini / meteor-scss

Sass and SCSS support for Meteor and M1 CPUs (arm64)
MIT License
2 stars 1 forks source link

Fails in Meteor 2 #1

Open perbergland opened 1 month ago

perbergland commented 1 month ago

Bug report

meteor version: 2.16

leonardoventurini:scss version: 1.1.1

I get this stack trace in an error during build:

/Users/redacted/.meteor/packages/meteor-tool/.2.16.0.g8yvo.k9wfpt++os.osx.arm64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.arm64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:75:12:
   Cannot await without a Fiber
   at awaitPromise
   (/Users/redacted/.meteor/packages/meteor-tool/.2.16.0.g8yvo.k9wfpt++os.osx.arm64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.arm64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:75:12)
   at Promise.await
   (/Users/redacted/.meteor/packages/meteor-tool/.2.16.0.g8yvo.k9wfpt++os.osx.arm64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.arm64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:60:12)
   at CssOutputResource.finalize (/tools/isobuild/compiler-plugin.js:930:12)
   at CssOutputResource.hasPendingErrors (/tools/isobuild/compiler-plugin.js:935:10)
   at CssOutputResource._get (/tools/isobuild/compiler-plugin.js:966:14)
   at CssOutputResource.get data (/tools/isobuild/compiler-plugin.js:950:28)
   at ResourceSlot.addStylesheet (/tools/isobuild/compiler-plugin.js:784:41)
   at InputFile.addStylesheet (/tools/isobuild/compiler-plugin.js:476:24)
   at SassCompiler.compileOneFileLater (<runJavaScript-31>:91:15)

It might indicate that the compileOneFileLater method returns a promise that isn’t wrapped in Meteor.bindEnvironment.

perbergland commented 1 month ago

After cloning the repo into packages, I can no longer reproduce the error.

I suspect that this is because when building for Meteor 3 to ensure that it is compatible with both versions, the compiled code will not be processed by reify to have await calls converted to Promise.await.

https://github.com/leonardoventurini/meteor-scss/blob/e6fa2740b8480583b6ced2f20c3d471d457a0405/plugin/sass-compiler.js#L47

One possible solution that is hard to test locally would be to create a Promise instance manually instead of using the await operator, but I’m not sure - I would ask zodern for advise…

perbergland commented 1 month ago

This might work, but I have no way of testing it… It will invoke the "safe" Promise.await when executing in meteor 2 and use native await in meteor 3

const result = Promise.await ? Promise.await(getResult()) : await getResult()