Created
August 9, 2014 04:27
-
-
Save wilsoncook/18c28ea76f1eac5c4c41 to your computer and use it in GitHub Desktop.
a test script for Nodejs's issue #8118
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//TEST issue #8118 | |
//Nodejs is attempting to re-create a http request if the request-handler may exec more time #8118 | |
//See: https://github.com/joyent/node/issues/8118 | |
console.log('/******* Current Node *******/'); | |
console.log(process.versions); | |
console.log(process.platform); | |
console.log('/****************************/'); | |
var test_timeout_visited = false; | |
var test_timeout_count = 0; | |
var http = require('http'); | |
http.createServer(function (req, res) { | |
// debugger; | |
console.log('current url: %s', req.url); | |
if (req.url == '/test_first') { | |
console.log('now at the "test_first" request'); | |
res.end('test_first'); | |
} else if (req.url == '/test_run_task') { | |
if (!test_timeout_visited) { | |
// debugger; | |
console.log('now at the "RUN TASK" request'); | |
test_timeout_visited = true; | |
var tmpfunc = function () { | |
// if (test_timeout_count >= 9) debugger; | |
if (test_timeout_count > 15) { | |
console.log('ok, task done!'); | |
res.end('task complete'); | |
return ; | |
} | |
console.log('complete %s', (test_timeout_count++)); | |
setTimeout(tmpfunc, 10 * 1000); | |
}; | |
tmpfunc(); | |
} else { | |
// debugger; | |
console.log('[!!!WARNING!!!] now at the "DUPLICATE" request'); | |
res.end('duplicate request'); | |
} | |
} | |
}).listen(3000, '127.0.0.1'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment