tjanczuk/iisnode — Issue #65: w3wp stops processing request when node.exe process becomes unresponsive
Author: markcowl
Created: 2011-11-01 02:32:43+00:00
State: open

The scenario is meant to mimic an unresponsive node.exe process – the node server app enters an endless loop when a certain querystring is received. The behavior I see from iisnode, is that subsequent attempts to send requests to the application fail – no new node process is spun up, and requests hang.

ETW traces and server js are attached.

To repro, place a get request to
?spin

to start the endless loop, then place any subsequent requests to

You can try to send requests to first to see what should occur (essentially 11 blocks in a plain text response, with each block returned after 10 seconds).

Here is the source for the server:

var http = require('http');
var url = require('url');
console.log("port: " + process.env.PORT);

http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
requestDispatch(req, res);
}).listen(process.env.PORT);

function endWrite( httpResponse, intervalId)
{
clearInterval(intervalId);
httpResponse.end("\nended");
}

function clearWriteInterval( httpResponse, intervalId)
{
clearInterval(intervalId);
}

function normalWrite( httpRequest, httpResponse)
{
var writeInterval = setInterval( function( httpResponse) { httpResponse.write("\n block");}, 1000, httpResponse);
var endTimeout = setTimeout( endWrite, 10000, httpResponse, writeInterval);
}

function unendingWrite(httpRequest, httpResponse)
{
var writeInterval = setInterval( function( httpResponse) { httpResponse.write("\n block");}, 1000, httpResponse);
var endTimeout = setTimeout( clearWriteInterval, 10000, httpResponse, writeInterval);
}

function uhe( httpRequest, httpResponse)
{
console.log("throwing exception");
throw "Exception thrown by design";
}

function endlessLoop( httpRequest, httpResponse)
{
console.log("entering endless loop");
while (true) {}
}

function processShutdown( httpRequest, httpResponse)
{
console.log("Cleanly shutting down process");
process.exit(1);
}

function requestDispatch( httpRequest, httpResponse)
{
var parsedUrl = url.parse(httpRequest.url);
if (parsedUrl.query && parsedUrl.query.length > 0)
{
if (parsedUrl.query.indexOf("uhe") >= 0)
{
uhe( httpRequest, httpResponse);
}
else if (parsedUrl.query.indexOf("shutdown") >= 0)
{
processShutdown( httpRequest, httpResponse);
}
else if (parsedUrl.query.indexOf("spin") >= 0)
{
endlessLoop( httpRequest, httpResponse);
}
else
{
unendingWrite( httpRequest, httpResponse);
}
}
else
{
normalWrite( httpRequest, httpResponse);
}
}