{"action":"created","issue":{"url":"https://api.github.com/repos/iccicci/rotating-file-stream/issues/17","repository_url":"https://api.github.com/repos/iccicci/rotating-file-stream","labels_url":"https://api.github.com/repos/iccicci/rotating-file-stream/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/iccicci/rotating-file-stream/issues/17/comments","events_url":"https://api.github.com/repos/iccicci/rotating-file-stream/issues/17/events","html_url":"https://github.com/iccicci/rotating-file-stream/issues/17","id":267117230,"number":17,"title":"Example use of generator fails with \"write after end\" error.","user":{"login":"ZiCog","id":2519277,"avatar_url":"https://avatars3.githubusercontent.com/u/2519277?v=4","gravatar_id":"","url":"https://api.github.com/users/ZiCog","html_url":"https://github.com/ZiCog","followers_url":"https://api.github.com/users/ZiCog/followers","following_url":"https://api.github.com/users/ZiCog/following{/other_user}","gists_url":"https://api.github.com/users/ZiCog/gists{/gist_id}","starred_url":"https://api.github.com/users/ZiCog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZiCog/subscriptions","organizations_url":"https://api.github.com/users/ZiCog/orgs","repos_url":"https://api.github.com/users/ZiCog/repos","events_url":"https://api.github.com/users/ZiCog/events{/privacy}","received_events_url":"https://api.github.com/users/ZiCog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"iccicci","id":878486,"avatar_url":"https://avatars1.githubusercontent.com/u/878486?v=4","gravatar_id":"","url":"https://api.github.com/users/iccicci","html_url":"https://github.com/iccicci","followers_url":"https://api.github.com/users/iccicci/followers","following_url":"https://api.github.com/users/iccicci/following{/other_user}","gists_url":"https://api.github.com/users/iccicci/gists{/gist_id}","starred_url":"https://api.github.com/users/iccicci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iccicci/subscriptions","organizations_url":"https://api.github.com/users/iccicci/orgs","repos_url":"https://api.github.com/users/iccicci/repos","events_url":"https://api.github.com/users/iccicci/events{/privacy}","received_events_url":"https://api.github.com/users/iccicci/received_events","type":"User","site_admin":false},"assignees":[{"login":"iccicci","id":878486,"avatar_url":"https://avatars1.githubusercontent.com/u/878486?v=4","gravatar_id":"","url":"https://api.github.com/users/iccicci","html_url":"https://github.com/iccicci","followers_url":"https://api.github.com/users/iccicci/followers","following_url":"https://api.github.com/users/iccicci/following{/other_user}","gists_url":"https://api.github.com/users/iccicci/gists{/gist_id}","starred_url":"https://api.github.com/users/iccicci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iccicci/subscriptions","organizations_url":"https://api.github.com/users/iccicci/orgs","repos_url":"https://api.github.com/users/iccicci/repos","events_url":"https://api.github.com/users/iccicci/events{/privacy}","received_events_url":"https://api.github.com/users/iccicci/received_events","type":"User","site_admin":false}],"milestone":null,"comments":18,"created_at":"2017-10-20T09:33:16Z","updated_at":"2018-04-26T15:03:47Z","closed_at":null,"author_association":"NONE","body":"The example use of a generator function in the documentation fails with \"write after end\" error:\r\n\r\nSimple program to reproduce this is:\r\n\r\n```\r\nvar rfs    = require('rotating-file-stream');\r\n\r\nfunction pad(num) {\r\n    return (num > 9 ? \"\" : \"0\") + num;\r\n}\r\n\r\nfunction generator(time, index) {\r\n    if(! time)\r\n        return \"file.log\";\r\n\r\n    var month  = time.getFullYear() + \"\" + pad(time.getMonth() + 1);\r\n    var day    = pad(time.getDate());\r\n    var hour   = pad(time.getHours());\r\n    var minute = pad(time.getMinutes());\r\n\r\n    return \"/storage/\" + month + \"/\" + month +\r\n        day + \"-\" + hour + minute + \"-\" + index + \"-file.log\";\r\n}\r\n\r\nvar stream = rfs(generator, {\r\n    size:     '1M',\r\n    interval: '30m'\r\n});\r\n\r\nsetInterval(function () {\r\n    stream.write('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');\r\n}, 10);\r\n\r\n```\r\n\r\nUsing node 8.4.0 on Bash on Windows 10.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/iccicci/rotating-file-stream/issues/comments/384673978","html_url":"https://github.com/iccicci/rotating-file-stream/issues/17#issuecomment-384673978","issue_url":"https://api.github.com/repos/iccicci/rotating-file-stream/issues/17","id":384673978,"user":{"login":"electrotype","id":1643012,"avatar_url":"https://avatars2.githubusercontent.com/u/1643012?v=4","gravatar_id":"","url":"https://api.github.com/users/electrotype","html_url":"https://github.com/electrotype","followers_url":"https://api.github.com/users/electrotype/followers","following_url":"https://api.github.com/users/electrotype/following{/other_user}","gists_url":"https://api.github.com/users/electrotype/gists{/gist_id}","starred_url":"https://api.github.com/users/electrotype/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/electrotype/subscriptions","organizations_url":"https://api.github.com/users/electrotype/orgs","repos_url":"https://api.github.com/users/electrotype/repos","events_url":"https://api.github.com/users/electrotype/events{/privacy}","received_events_url":"https://api.github.com/users/electrotype/received_events","type":"User","site_admin":false},"created_at":"2018-04-26T15:03:46Z","updated_at":"2018-04-26T15:03:46Z","author_association":"NONE","body":"So here's the error I get!\r\n\r\n```\r\nRotating File Stream error:  { Error: EEXIST: file already exists, mkdir 'C:\\_julien\\dev\\mtl\\xxxxnode-api\\log'                                                                                                           \r\n  errno: -4075,                                                                                                                                                                                                                             \r\n  code: 'EEXIST',                                                                                                                                                                                                                           \r\n  syscall: 'mkdir',                                                                                                                                                                                                                         \r\n  path: 'C:\\\\_julien\\\\dev\\\\mtl\\\\xxxxnode-api\\\\log' }                                                                                                                                                                     \r\nRotating File Stream error:  { Error: EEXIST: file already exists, mkdir 'C:\\_julien\\dev\\mtl\\xxxxnode-api\\log'                                                                                                           \r\n  errno: -4075,                                                                                                                                                                                                                             \r\n  code: 'EEXIST',                                                                                                                                                                                                                           \r\n  syscall: 'mkdir',                                                                                                                                                                                                                         \r\n  path: 'C:\\\\_julien\\\\dev\\\\mtl\\\\xxxxnode-api\\\\log' }                                                                                                                                                                     \r\nRotating File Stream error:  { Error: EEXIST: file already exists, mkdir 'C:\\_julien\\dev\\mtl\\xxxxnode-api\\log'                                                                                                           \r\n  errno: -4075,                                                                                                                                                                                                                             \r\n  code: 'EEXIST',                                                                                                                                                                                                                           \r\n  syscall: 'mkdir',                                                                                                                                                                                                                         \r\n  path: 'C:\\\\_julien\\\\dev\\\\mtl\\\\xxxxnode-api\\\\log' }                                                                                                                                                                     \r\nRotating File Stream error:  { Error: EEXIST: file already exists, mkdir 'C:\\_julien\\dev\\mtl\\xxxxnode-api\\log'                                                                                                           \r\n  errno: -4075,                                                                                                                                                                                                                             \r\n  code: 'EEXIST',                                                                                                                                                                                                                           \r\n  syscall: 'mkdir',                                                                                                                                                                                                                         \r\n  path: 'C:\\\\_julien\\\\dev\\\\mtl\\\\xxxxnode-api\\\\log' }  \r\n\r\nThe `log` directory indeen already exist! I guess the problem is that RFS triws to create it anyway, in some situations...\r\n```"}}
{"actor":{"display_login":"electrotype"}}