| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6539c64 commit 7f1e3e9
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,9 @@ const assert = require('assert'); | |||
| 12 | 12 | // Normally when the writable stream emits a 'drain' event, the server then | |
| 13 | 13 | // uncorks the readable stream, although we arent testing that part here. | |
| 14 | 14 | ||
| 15 | + // The issue being tested exists in Node.js 0.10.20 and is resolved in 0.10.21 | ||
| 16 | + // and newer. | ||
| 17 | + | ||
| 15 | 18 | switch (process.argv[2]) { | |
| 16 | 19 | case undefined: | |
| 17 | 20 | return parent(); | |
@@ -24,8 +27,6 @@ switch (process.argv[2]) { | |||
| 24 | 27 | function parent() { | |
| 25 | 28 | const http = require('http'); | |
| 26 | 29 | const bigResponse = new Buffer(10240).fill('x'); | |
| 27 | - var gotTimeout = false; | ||
| 28 | - var childClosed = false; | ||
| 29 | 30 | var requests = 0; | |
| 30 | 31 | var connections = 0; | |
| 31 | 32 | var backloggedReqs = 0; | |
@@ -57,20 +58,16 @@ function parent() { | |||
| 57 | 58 | const spawn = require('child_process').spawn; | |
| 58 | 59 | const args = [__filename, 'child']; | |
| 59 | 60 | const child = spawn(process.execPath, args, { stdio: 'inherit' }); | |
| 60 | - child.on('close', function() { | ||
| 61 | - childClosed = true; | ||
| 61 | + child.on('close', common.mustCall(function() { | ||
| 62 | 62 | server.close(); | |
| 63 | - }); | ||
| 63 | + })); | ||
| 64 | 64 | ||
| 65 | - server.setTimeout(common.platformTimeout(200), function(conn) { | ||
| 66 | - gotTimeout = true; | ||
| 65 | + server.setTimeout(200, common.mustCall(function() { | ||
| 67 | 66 | child.kill(); | |
| 68 | - }); | ||
| 67 | + })); | ||
| 69 | 68 | }); | |
| 70 | 69 | ||
| 71 | 70 | process.on('exit', function() { | |
| 72 | - assert(gotTimeout); | ||
| 73 | - assert(childClosed); | ||
| 74 | 71 | assert.equal(connections, 1); | |
| 75 | 72 | }); | |
| 76 | 73 | } | |
@@ -85,13 +82,10 @@ function child() { | |||
| 85 | 82 | ||
| 86 | 83 | req = new Array(10241).join(req); | |
| 87 | 84 | ||
| 88 | - conn.on('connect', function() { | ||
| 89 | - // Terminate child after flooding. | ||
| 90 | - setTimeout(function() { conn.destroy(); }, common.platformTimeout(1000)); | ||
| 91 | - write(); | ||
| 92 | - }); | ||
| 85 | + conn.on('connect', write); | ||
| 93 | 86 | ||
| 94 | - conn.on('drain', write); | ||
| 87 | + // `drain` should fire once and only once | ||
| 88 | + conn.on('drain', common.mustCall(write)); | ||
| 95 | 89 | ||
| 96 | 90 | function write() { | |
| 97 | 91 | while (false !== conn.write(req, 'ascii')); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments