{"action":"created","issue":{"url":"https://api.github.com/repos/joyent/node/issues/5603","labels_url":"https://api.github.com/repos/joyent/node/issues/5603/labels{/name}","comments_url":"https://api.github.com/repos/joyent/node/issues/5603/comments","events_url":"https://api.github.com/repos/joyent/node/issues/5603/events","html_url":"https://github.com/joyent/node/issues/5603","id":14944044,"number":5603,"title":"Writing to ended write stream continues without error","user":{"login":"alexwhitman","id":422013,"avatar_url":"https://avatars.githubusercontent.com/u/422013?v=3","gravatar_id":"","url":"https://api.github.com/users/alexwhitman","html_url":"https://github.com/alexwhitman","followers_url":"https://api.github.com/users/alexwhitman/followers","following_url":"https://api.github.com/users/alexwhitman/following{/other_user}","gists_url":"https://api.github.com/users/alexwhitman/gists{/gist_id}","starred_url":"https://api.github.com/users/alexwhitman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexwhitman/subscriptions","organizations_url":"https://api.github.com/users/alexwhitman/orgs","repos_url":"https://api.github.com/users/alexwhitman/repos","events_url":"https://api.github.com/users/alexwhitman/events{/privacy}","received_events_url":"https://api.github.com/users/alexwhitman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/joyent/node/labels/streams","name":"streams","color":"e10c02"}],"state":"closed","locked":false,"assignee":{"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},"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":9,"closed_issues":81,"state":"open","created_at":"2012-04-06T01:03:06Z","updated_at":"2015-05-26T22:35:35Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2013-05-30T14:48:08Z","updated_at":"2015-05-26T22:35:35Z","closed_at":"2015-05-26T22:35:35Z","body":"Not sure if this is a bug but it seems odd.\r\n\r\nRunning the following testcase:\r\n```javascript\r\nvar fs = require('fs');\r\n\r\nvar files = [\r\n\t__dirname + '/1.txt',\r\n\t__dirname + '/2.txt',\r\n\t__dirname + '/3.txt'\r\n];\r\n\r\nvar outFile = __dirname + '/out.txt';\r\n\r\nconcat(files, outFile, function() {\r\n\tconsole.log(fs.readFileSync(outFile).toString());\r\n});\r\n\r\nfunction concat(files, outFile, cb) {\r\n\r\n\tvar writer = fs.createWriteStream(outFile);\r\n\twriter.on('error', function(err) {\r\n\t\tconsole.log(err);\r\n\t});\r\n\r\n\tfunction iterate() {\r\n\t\tconsole.log('iterating');\r\n\t\tif (files.length === 0) {\r\n\t\t\treturn cb();\r\n\t\t}\r\n\r\n\t\tvar path = files.shift();\r\n\t\tvar reader = fs.createReadStream(path);\r\n\t\treader.on('error', function(err) {\r\n\t\t\tconsole.log(err);\r\n\t\t});\r\n\t\treader.on('end', function() {\r\n\t\t\tconsole.log('end');\r\n\t\t\titerate();\r\n\t\t});\r\n\t\treader.pipe(writer);\r\n\t}\r\n\r\n\titerate();\r\n\r\n}\r\n```\r\n\r\nproduced an output of:\r\n```\r\niterating\r\nend\r\niterating\r\n```\r\n\r\nI eventually figured out why things weren't working as I expected (`pipe()` ends by default) and fixed it but I thought it was odd that the script continued while trying to `pipe()` for the second time with no error.\r\n\r\nShould the WriteStream have emitted `error` in this case?\r\n\r\nNode.js version 0.10.8"},"comment":{"url":"https://api.github.com/repos/joyent/node/issues/comments/105688921","html_url":"https://github.com/joyent/node/issues/5603#issuecomment-105688921","issue_url":"https://api.github.com/repos/joyent/node/issues/5603","id":105688921,"user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T22:35:35Z","updated_at":"2015-05-26T22:35:35Z","body":"No longer happening in v0.12. Closing, can reopen if necessary"}}