diff --git a/Microsoft.AspNet.NodeServices/Content/Node/entrypoint-http.js b/Microsoft.AspNet.NodeServices/Content/Node/entrypoint-http.js index f19c114..153d94f 100644 --- a/Microsoft.AspNet.NodeServices/Content/Node/entrypoint-http.js +++ b/Microsoft.AspNet.NodeServices/Content/Node/entrypoint-http.js @@ -20,7 +20,13 @@ var server = http.createServer(function(req, res) { if (!hasSentResult) { hasSentResult = true; if (errorValue) { - res.status(500).send(errorValue); + res.statusCode = 500; + + if (errorValue.stack) { + res.end(errorValue.stack); + } else { + res.end(errorValue.toString()); + } } else if (typeof successValue !== 'string') { // Arbitrary object/number/etc - JSON-serialize it res.setHeader('Content-Type', 'application/json'); diff --git a/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs b/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs index b863ad1..d987df3 100644 --- a/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs +++ b/Microsoft.AspNet.NodeServices/HostingModels/HttpNodeInstance.cs @@ -1,3 +1,5 @@ +using System; +using System.Net; using System.Net.Http; using System.Text; using System.Text.RegularExpressions; @@ -29,6 +31,11 @@ namespace Microsoft.AspNet.NodeServices { var payload = new StringContent(payloadJson, Encoding.UTF8, "application/json"); var response = await client.PostAsync("http://localhost:" + this._portNumber, payload); var responseString = await response.Content.ReadAsStringAsync(); + + if (response.StatusCode != HttpStatusCode.OK) { + throw new Exception("Node module responded with error: " + responseString); + } + var responseIsJson = response.Content.Headers.ContentType.MediaType == "application/json"; if (responseIsJson) { return JsonConvert.DeserializeObject(responseString);