-
Notifications
You must be signed in to change notification settings - Fork 69
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
Exits Meteor 1.0 #11
Comments
I'm probably not familiar enough with Meteor to be of much assistance, it looks like you are calling correctly to me. But if you are on the server anyway, I'd propose calling out to the real C lib xmllint vis-a-vis node |
The site hosting the Windows binaries of xmllint is down, and XMLStarlet doesn't provide details, so i hacked up a Node wrapper for fs = require('fs')
// process.argv = [ 'node', 'path\\xmllint.js.app', 'the.xml', 'the.xsd' ]
xml = fs.readFileSync(process.argv[2])
xsd = fs.readFileSync(process.argv[3])
eval(''+fs.readFileSync(__dirname+'/xmllint.js.lib')) // http://stackoverflow.com/a/5809968/819417
result = xmllint.validateXML({xml: xml, schema: xsd})
if(result.errors) console.log('XML ERR', result.errors)
else console.log('XML OK') Calling it using non-.js names to exclude it from Meteor: exec = Meteor.wrapAsync(Npm.require('child_process').exec)
#command = process.cwd().split('.meteor')[0] + "server\\xml.exe val --xsd #{app_path}server/company.xsd #{xmlfile}"
command = "\"C:/Program Files (x86)/nodejs/node.exe\" #{app_path}server/xmllint.js.app #{xmlfile} #{app_path}server/company.xsd"
#console.log command
console.log exec(command) ...which does weird things on error, so i use a Future instead: Future = Npm.require 'fibers/future'
fut = new Future()
exec(command, (error, stdout, stderr)->
#console.log('error', error) # Non-zero exit, error.code
#console.log('stdout', stdout) # Errors are here.
#console.log('stderr', stderr) # Not even when there's an error.
fut.return(stdout)
)
console.log fut.wait() |
It's very strange. The main file is set up to export as a |
Or something with Windows. It would be interesting to run your project in a Linux VM just to see what if anything was different. |
Meteor's To repro, run this: meteor create test
cd test
meteor add meteorhacks:npm
meteor Then add if(Meteor.isClient){
Session.setDefault('counter', 0)
Template.hello.helpers({
counter: function(){
return Session.get('counter')
}
})
Template.hello.events({
'click button': function(){
Session.set('counter', Session.get('counter') + 1)
Meteor.call('validate')
}
})
}
if(Meteor.isServer){
Meteor.methods({
validate: function(){
var command = "\"C:/Program Files (x86)/nodejs/node.exe\" assets/app/xmllintwrapper.js assets/app/any.xml "+process.cwd().split('.meteor')[0]+"private/any.xsd"
console.log("COMMAND", command)
try{
// WORKS but FAILS as it restarts Meteor! ([email protected] according to result. 1.0 according to Windows 10 Control Panel\All Control Panel Items\Programs and Features) - Caused by change in project folder?
var xmllint = Meteor.npmRequire('xmllint')
var fs = Npm.require('fs')
var xml = fs.readFileSync(process.cwd().split('.meteor')[0] + 'private/any.xml', 'utf8')
var xsd = fs.readFileSync(process.cwd().split('.meteor')[0] + 'private/any.xsd', 'utf8')
result = xmllint.validateXML({xml: xml, schema: xsd})
// FAILS:
/*
var exec = Meteor.wrapAsync(Npm.require('child_process').exec)
console.log(exec(command))
*/
// WORKS:
/*
var exec = Npm.require('child_process').exec
Future = Npm.require('fibers/future')
fut = new Future()
exec(command, function(error, stdout, stderr){
console.log('error:', error) // Non-zero exit, error.code
console.log('stdout:', stdout) // Errors are here.
console.log('stderr:', stderr) // Not even when there's an error.
fut.return(stdout)
})
result = fut.wait()
*/
}catch(er){console.log(er.stack)}
}
})
Meteor.startup(function(){})
} |
In case github doesn't send edit notifications: I've added the case of my first post. |
You should probably also file a similar issue to the meteor team. Xmllint is fully self contained and valid js so running it should not force a meteor restart of the container. I'd bet they are aware of issues that can cause this when running js. |
Also is 'result' being assigned to without first declaring it as 'var'? |
I've linked this issue to the error handling issue and CoffeeScript autogenerates |
I'm experiencing the same issue, but in a Node.js (4.2.2) + Windows 10 environment. The I see this ticket has been open for a few months now. @sterpe: Is there any possibility of finding a resolution soon? |
@JakeDetels, are you experiencing the same issue with Meteor or apart from Meteor? |
@JakeDetels I'm not able to reproduce this issue with node itself using any [email protected]/5.x/6.x Here is my rather trivial test var fs = require('fs')
, xmllint = require('xmllint')
, xml = fs.readFileSync('./test/test.xml').toString()
, schema = fs.readFileSync('./test/test.xsd').toString()
;
console.log(xmllint.validateXML({
xml: [xml, xml],
schema: [schema, schema]
}));
while (1) {
} The test files are the same in Can you provide a reproduction? |
@sterpe Your reproduction looks fair. I'm not sure what's happening with @JakeDetels – though it definitely sounds familiar. I reproduced @CTimmerman's issue on Meteor with
It looks similar to emscripten-core/emscripten#2047 . Meteor server runs synchronously versus Node's normal async and usually wrapping in a Fiber will fix things but I don't quite understand what's going on in this case. Any ideas? |
Hard to tell from the stack trace. But |
You can use my fork https://github.com/Beat-YT/xml.js |
Using Meteor 1.0, CoffeeScript, and https://github.com/meteorhacks/npm this works on the server:
However, as soon as the function that code is in is done, Meteor restarts with "=> Exited with code: 0", where 0 is the exit code of xmllint, as when it found errors in xml or xsd, the code was 3 or 5.
The text was updated successfully, but these errors were encountered: