-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Synchronous custom importer not providing done #997
Comments
Related to #849, linkedin/eyeglass#30 |
Looks like we pass the callback bridge as the third parameter (from C++, not to your JS callback), but the values are not used. Need to investigate. |
So far I've tried https://github.com/DominicBarnard/node-sass/commit/812c5b88860f34fd4bc8ce128dc68c7c24c131b1 but my new tests are still failing :/ |
You can cheat it this way saper@1417658 |
ok so that passes my tests now. But I expect that will break when an importer actually uses |
On Wed, 10 Jun 2015, Dominic Barnard wrote:
ok so that passes my tests now. But I expect that will break when an importer actually uses `readFile` to async load a file?
Your importer might return before your callback gets a chance to return something meaningful... Needs
to be tested, it's too late for me to guess
|
Yes this test is failing. |
Do you think it's useful to support this or maybe importers that want to support renderSync should just stick to sync operations and returning results? |
On Wed, 10 Jun 2015, Dominic Barnard wrote:
Do you think it's useful to support this or maybe importers that want to support renderSync should just stick to sync operations and returning results?
Definitely, you don't want to hang around waiting for all the callbacks
to return only in order to bring back the results.
What I am wondering right now is if there is a way to make an importer interface
more helpful. Would "return" work for both async and sync cases?
~
|
As far as i understand it, if you only have return available, it can work for both render and renderSync but only synchronous operations will be possible inside the importer. So no possibility of say importing files from the network. |
I think it's clean and well understood to have return for sync and done for async as long as developers know to only be async if they need to because they will loose support for renderSync and let the edge case of projects using renderSync and expecting to do async stuff like fetching from the network figure it out. Maybe just emit a meaningful error message from renderSync when nothing is returned that helps devs track a down a module which is trying to be async. |
I am sorry but we will drop this one. Do not mix sync and async interfaces. |
- ignore include folder since these only come from the build - fixes sass#997
As I understand from the docs, a custom importer should be able to handle both
render
andrenderSync
by callingdone()
asynchronously. So a single importer can load files with the asyncreadFile()
and be handled correctly by bothrender
andrenderSync
.If this is correct then I'm seeing a bug as when I run the following code,
done
is showing up asundefined
. This is what I believe is causing errors in the current implementation of eyeglass when run withrenderSync
which relies on callingdone
.The text was updated successfully, but these errors were encountered: