Open askie opened 9 years ago
Can you post a script and XML that reproduces this error?
I'm getting the same error
xml2js = require "xml2js"
parser = new xml2js.Parser()
_pullBookings: (params, callback) ->
body = require("./resources/xmlPostBody")(params)
postRequest =
host: "..."
path: "..."
method: "POST"
port: 80
SOAPAction: "..."
headers:
'Content-Type': 'text/xml'
'Content-Length': Buffer.byteLength(body)
req = https.request postRequest, (res) ->
buffer = "";
res.on "data", (data) ->
buffer = buffer + data;
res.on "end", ->
parser.parseString buffer, (err, result) -> # error happens here
XMLStringResponse = result['soap:Envelope']['soap:Body'][0]['GetAllBookingsResponse'][0]['GetAllBookingsResult'][0]
if (XMLStringResponse.length > 12) # probably not empty
parser.parseString XMLStringResponse , (err, result) ->
callback(result)
else
callback()
req.on 'error', (e) ->
logger.log 'problem with EMS request: ' + e.message
req.write( body );
req.end();
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAllBookingsResponse xmlns="http://DEA.EMS.API.Web.Service/"><GetAllBookingsResult><Bookings /></GetAllBookingsResult></GetAllBookingsResponse></soap:Body></soap:Envelope>
thanks
If your callback somehow throws an exception which is not instanceof Error, you can get this.
parseString(buffer, function(err, result) {
// this is problematic
throw 'this is unspecified';
// use this instead
throw new Error('this is specified');
});
I got this issue even though I'm not throwing any exceptions at all in my callback - I just had a ReferenceError
, and it was a pain in the ass to track down since all the info I got was "Uncaught, unspecified 'error' event."
.
And I did see the attempted fix in #138 - I'm on version 0.4.9 and it's still broken.