{"action":"closed","issue":{"url":"https://api.github.com/repos/joyent/node/issues/7077","labels_url":"https://api.github.com/repos/joyent/node/issues/7077/labels{/name}","comments_url":"https://api.github.com/repos/joyent/node/issues/7077/comments","events_url":"https://api.github.com/repos/joyent/node/issues/7077/events","html_url":"https://github.com/joyent/node/issues/7077","id":27200672,"number":7077,"title":"net: unref() is not persistent","user":{"login":"bnoordhuis","id":275871,"avatar_url":"https://avatars.githubusercontent.com/u/275871?v=3","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/joyent/node/labels/net","name":"net","color":"e10c02"}],"state":"closed","locked":false,"assignee":{"login":"cjihrig","id":2512748,"avatar_url":"https://avatars.githubusercontent.com/u/2512748?v=3","gravatar_id":"","url":"https://api.github.com/users/cjihrig","html_url":"https://github.com/cjihrig","followers_url":"https://api.github.com/users/cjihrig/followers","following_url":"https://api.github.com/users/cjihrig/following{/other_user}","gists_url":"https://api.github.com/users/cjihrig/gists{/gist_id}","starred_url":"https://api.github.com/users/cjihrig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjihrig/subscriptions","organizations_url":"https://api.github.com/users/cjihrig/orgs","repos_url":"https://api.github.com/users/cjihrig/repos","events_url":"https://api.github.com/users/cjihrig/events{/privacy}","received_events_url":"https://api.github.com/users/cjihrig/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/joyent/node/milestones/14","html_url":"https://github.com/joyent/node/milestones/v0.10","labels_url":"https://api.github.com/repos/joyent/node/milestones/14/labels","id":104564,"number":14,"title":"v0.10","description":"","creator":{"login":"isaacs","id":9287,"avatar_url":"https://avatars.githubusercontent.com/u/9287?v=3","gravatar_id":"","url":"https://api.github.com/users/isaacs","html_url":"https://github.com/isaacs","followers_url":"https://api.github.com/users/isaacs/followers","following_url":"https://api.github.com/users/isaacs/following{/other_user}","gists_url":"https://api.github.com/users/isaacs/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacs/subscriptions","organizations_url":"https://api.github.com/users/isaacs/orgs","repos_url":"https://api.github.com/users/isaacs/repos","events_url":"https://api.github.com/users/isaacs/events{/privacy}","received_events_url":"https://api.github.com/users/isaacs/received_events","type":"User","site_admin":false},"open_issues":11,"closed_issues":79,"state":"open","created_at":"2012-04-06T01:03:06Z","updated_at":"2015-05-19T18:27:22Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2014-02-08T13:47:32Z","updated_at":"2015-05-19T18:27:21Z","closed_at":"2015-05-19T18:27:21Z","body":"```javascript\r\nvar net = require('net');\r\nvar server = net.createServer();\r\nserver.unref();\r\nserver.listen();\r\nnet.connect(server.address().port).unref();\r\n```\r\n\r\nIt hangs because of the unref() that comes before listen() and the one after connect().  In that vein:\r\n\r\n```javascript\r\nrequire('net').connect(42).unref();\r\n```\r\n\r\nIt fails with ECONNREFUSED because the unref() is a no-op.  The expected behavior for both scripts is that they simply quit.  Affects v0.10 and master.\r\n\r\nThe documentation doesn't mention when it's okay to call unref().  For the sake of user friendliness, net.Socket and net.Server should remember the ref state and retroactively apply it when the handle is created.  Probably applies to other handle types as well."}}