Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Synchronous custom importer not providing done #997

Closed
ghost opened this issue Jun 10, 2015 · 13 comments
Closed

Synchronous custom importer not providing done #997

ghost opened this issue Jun 10, 2015 · 13 comments

Comments

@ghost
Copy link

ghost commented Jun 10, 2015

As I understand from the docs, a custom importer should be able to handle both render and renderSync by calling done() asynchronously. So a single importer can load files with the async readFile() and be handled correctly by both render and renderSync.

If this is correct then I'm seeing a bug as when I run the following code, done is showing up as undefined. This is what I believe is causing errors in the current implementation of eyeglass when run with renderSync which relies on calling done.

sass.renderSync({
    file: 'sass/test.scss',
    importer: function (uri, prev, done) {
        console.log(done); \\ logs undefined
    }
}, function(err, result) {
    console.log('successfully rendered');
});
@ghost
Copy link
Author

ghost commented Jun 10, 2015

Related to #849, linkedin/eyeglass#30

@ghost
Copy link
Author

ghost commented Jun 10, 2015

Some failing tests

@saper
Copy link
Member

saper commented Jun 10, 2015

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.

@ghost
Copy link
Author

ghost commented Jun 10, 2015

So far I've tried https://github.com/DominicBarnard/node-sass/commit/812c5b88860f34fd4bc8ce128dc68c7c24c131b1 but my new tests are still failing :/
Error: file to import not found or unreadable: foo Current dir:

saper added a commit to saper/node-sass that referenced this issue Jun 10, 2015
@saper
Copy link
Member

saper commented Jun 10, 2015

You can cheat it this way saper@1417658

@ghost
Copy link
Author

ghost commented Jun 10, 2015

ok so that passes my tests now. But I expect that will break when an importer actually uses readFile to async load a file or does anything async?

@saper
Copy link
Member

saper commented Jun 10, 2015 via email

@ghost
Copy link
Author

ghost commented Jun 10, 2015

Yes this test is failing.

@ghost
Copy link
Author

ghost commented Jun 10, 2015

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?

@saper
Copy link
Member

saper commented Jun 10, 2015 via email

@ghost
Copy link
Author

ghost commented Jun 10, 2015

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.

@ghost
Copy link
Author

ghost commented Jun 10, 2015

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.

@saper
Copy link
Member

saper commented Oct 21, 2019

I am sorry but we will drop this one. Do not mix sync and async interfaces.

@saper saper closed this as completed Oct 21, 2019
jiongle1 pushed a commit to scantist-ossops-m2/node-sass that referenced this issue Apr 7, 2024
- ignore include folder since these only come from the build
- fixes sass#997
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants