Skip to content
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

Throws when data && file are null (an edge case) #776

Closed
am11 opened this issue Dec 26, 2014 · 6 comments
Closed

Throws when data && file are null (an edge case) #776

am11 opened this issue Dec 26, 2014 · 6 comments

Comments

@am11
Copy link
Contributor

am11 commented Dec 26, 2014

When an empty option set is sent to libsass, it chokes. :)
Same thing happens, when file and data options are empty or null.

//# this is 'node.js interactive console'

require("node-sass").renderSync({file:undefined})
// OR
require("node-sass").renderSync({file:null})
// OR
require("node-sass").renderSync({file:""})
// OR
require("node-sass").renderSync({data:undefined})
// OR
require("node-sass").renderSync({data:""})
// OR
require("node-sass").renderSync({data:"",file:""})
// OR
require("node-sass").renderSync({data:null,file:null})
// OR
require("node-sass").renderSync({data:undefined,file:undefined})
// OR permute undefined and null
// OR
require("node-sass").renderSync({})

// But this properly emits error:
require("node-sass").renderSync({file:"C:/temp/non-existing-path/blah.scss"})
/* returns:
{
  "status": 4,
  "message": "File to read not found or unreadable: C:/temp/non-existent-path/blah.scss"
}*/
// Also this is tolerable:
require("node-sass").renderSync({data:"messing around"})
/* returns:
{
  "status": 1,
  "file": "stdin",
  "line": 1,
  "column": 1,
  "message": "invalid top-level expression"
}*/
// And
require("node-sass").renderSync({data:null, file:"devnull"})
/* returns:
{
  "status": 4,
  "message": "File to read not found or unreadable: devnull"
}*/

Originally reported by @DinisCruz: sass/node-sass#554.

@mgreter
Copy link
Contributor

mgreter commented Dec 27, 2014

This should be fixed and you should now get a proper error on the context!

@mgreter mgreter closed this as completed Dec 27, 2014
@am11
Copy link
Contributor Author

am11 commented Dec 27, 2014

Thanks @mgreter! 👍

I will try it now.

@am11
Copy link
Contributor Author

am11 commented Dec 27, 2014

@mgreter, somehow the errors which were previously returned as JSON are coming as plain text. Is there something changed in sass_context_get_error_json()?

@mgreter
Copy link
Contributor

mgreter commented Dec 27, 2014

Nope, this should behave the same as before!

@am11
Copy link
Contributor Author

am11 commented Dec 27, 2014

After pulling the latest libsass master, it is giving me a plain text error:

require("node-sass").renderSync({data:"messing around"})
source string:1: error: invalid top-level expression

Which was previously producing:

{
  "status": 1,
  "file": "stdin",
  "line": 1,
  "column": 1,
  "message": "invalid top-level expression"
}

And segmentation fault if data is an empty string:

require("node-sass").renderSync({data:""})
Segmentation fault

@am11
Copy link
Contributor Author

am11 commented Dec 27, 2014

Sorry for the cry-wolf, recompiling fixes it! (crazy things happening today here) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants