Title: intermittent unexpected socket closure on Mac OS X · Issue #2610 · nodejs/node · GitHub
Open Graph Title: intermittent unexpected socket closure on Mac OS X · Issue #2610 · nodejs/node
X Title: intermittent unexpected socket closure on Mac OS X · Issue #2610 · nodejs/node
Description: Ref: #1100 Ref: nodejs/node-v0.x-archive#16805 The following code will throw on OS X. It might take a while but it will happen. I usually see the error before runcount hits 2000. 'use strict'; const fork = require('child_process').fork; ...
Open Graph Description: Ref: #1100 Ref: nodejs/node-v0.x-archive#16805 The following code will throw on OS X. It might take a while but it will happen. I usually see the error before runcount hits 2000. 'use strict'; cons...
X Description: Ref: #1100 Ref: nodejs/node-v0.x-archive#16805 The following code will throw on OS X. It might take a while but it will happen. I usually see the error before runcount hits 2000. 'use strict...
Opengraph URL: https://github.com/nodejs/node/issues/2610
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"intermittent unexpected socket closure on Mac OS X","articleBody":"Ref: https://github.com/nodejs/node/issues/1100\nRef: https://github.com/joyent/node/issues/16805\n\nThe following code will throw on OS X. It might take a while but it will happen. I usually see the error before runcount hits 2000.\n\n``` javascript\n'use strict';\nconst fork = require('child_process').fork;\nconst net = require('net');\nconst count = 12;\nconst port = 12346;\n\nif (process.argv[2] === 'child') {\n let sockets = [];\n\n process.on('message', function(m, socket) {\n function sendClosed(id) {\n process.send({ id: id, status: 'closed'});\n };\n\n if (m.cmd === 'new') {\n sockets.push(socket);\n }\n\n if (m.cmd === 'close') {\n if (sockets[m.id].destroyed) {\n throw new Error('socket already destroyed');\n }\n sockets[m.id].once('close', sendClosed.bind(null, m.id));\n sockets[m.id].destroy();\n }\n\n if (m.cmd === 'clear') {\n sockets = [];\n }\n });\n\n} else {\n const child = fork(process.argv[1], ['child']);\n\n const server = net.createServer();\n let sockets = [];\n\n server.on('connection', function(socket) {\n child.send({ cmd: 'new' }, socket);\n sockets.push(socket);\n\n if (sockets.length === count) {\n closeSockets(0);\n }\n });\n\n function createSockets() {\n let j = count, client;\n while (j--) {\n client = net.connect(port, '127.0.0.1');\n }\n }\n\n server.on('listening', function() {\n createSockets();\n });\n\n let runCount = 0;\n function closeSockets(i) {\n if (i === count) {\n console.log('run count: ' + ++runCount);\n child.send({ cmd: 'clear' });\n sockets = [];\n return createSockets();\n }\n\n child.once('message', function(m) {\n server.getConnections(function(err, num) {\n closeSockets(i + 1);\n });\n });\n child.send({ id: i, cmd: 'close' });\n };\n\n server.listen(port, '127.0.0.1');\n}\n```\n","author":{"url":"https://github.com/Trott","@type":"Person","name":"Trott"},"datePublished":"2015-08-29T04:12:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/2610/node/issues/2610"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c1ec9073-ab98-5c25-2b8e-2d37912d1117 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9FD0:6F3CF:33A7B3B:488A06B:6A4F8106 |
| html-safe-nonce | 8e96e2d0b705dfe2d415eca40b4a8953a202eb665a70e6373009b9bd44775772 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkQwOjZGM0NGOjMzQTdCM0I6NDg4QTA2Qjo2QTRGODEwNiIsInZpc2l0b3JfaWQiOiIyNDE2Nzc0Nzk2NDEyOTQ0NjQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f1d6563070a3d70f9d75e87dc5fd7012328abef88b0e1b24881f19647abb812d |
| hovercard-subject-tag | issue:103827494 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/2610/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7ae184bfce47108b933f60dc03e1700c1bdacd366f86d349d2a8c43e3ee4936e/nodejs/node/issues/2610 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ae184bfce47108b933f60dc03e1700c1bdacd366f86d349d2a8c43e3ee4936e/nodejs/node/issues/2610 |
| og:image:alt | Ref: #1100 Ref: nodejs/node-v0.x-archive#16805 The following code will throw on OS X. It might take a while but it will happen. I usually see the error before runcount hits 2000. 'use strict'; cons... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Trott |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width