| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f296a7f commit 98b721e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,15 @@ var server = net.createServer(function(s) { | |||
| 32 | 32 | var s = net.connect(common.PORT, function() { | |
| 33 | 33 | worker.send({}, s, callback); | |
| 34 | 34 | }); | |
| 35 | + | ||
| 36 | + // Errors can happen if this connection | ||
| 37 | + // is still happening while the server has been closed. | ||
| 38 | + s.on('error', function(err) { | ||
| 39 | + if ((err.code !== 'ECONNRESET') && | ||
| 40 | + ((err.code !== 'ECONNREFUSED'))) { | ||
| 41 | + throw err; | ||
| 42 | + } | ||
| 43 | + }); | ||
| 35 | 44 | } | |
| 36 | 45 | ||
| 37 | 46 | worker.process.once('close', common.mustCall(function() { | |
@@ -40,7 +49,14 @@ var server = net.createServer(function(s) { | |||
| 40 | 49 | server.close(); | |
| 41 | 50 | })); | |
| 42 | 51 | ||
| 43 | - // Send 2 handles to make `process.disconnect()` wait | ||
| 44 | - send(); | ||
| 45 | 52 | send(); | |
| 53 | + send(function(err) { | ||
| 54 | + // Ignore errors when sending the second handle because the worker | ||
| 55 | + // may already have exited. | ||
| 56 | + if (err) { | ||
| 57 | + if (err.code !== 'ECONNREFUSED') { | ||
| 58 | + throw err; | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + }); | ||
| 46 | 62 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments