{"action":"closed","issue":{"url":"https://api.github.com/repos/rvagg/node-levelup/issues/247","labels_url":"https://api.github.com/repos/rvagg/node-levelup/issues/247/labels{/name}","comments_url":"https://api.github.com/repos/rvagg/node-levelup/issues/247/comments","events_url":"https://api.github.com/repos/rvagg/node-levelup/issues/247/events","html_url":"https://github.com/rvagg/node-levelup/issues/247","id":33602710,"number":247,"title":"WriteStream: do not emit close until the callback","user":{"login":"dominictarr","id":259374,"avatar_url":"https://avatars.githubusercontent.com/u/259374?v=3","gravatar_id":"","url":"https://api.github.com/users/dominictarr","html_url":"https://github.com/dominictarr","followers_url":"https://api.github.com/users/dominictarr/followers","following_url":"https://api.github.com/users/dominictarr/following{/other_user}","gists_url":"https://api.github.com/users/dominictarr/gists{/gist_id}","starred_url":"https://api.github.com/users/dominictarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominictarr/subscriptions","organizations_url":"https://api.github.com/users/dominictarr/orgs","repos_url":"https://api.github.com/users/dominictarr/repos","events_url":"https://api.github.com/users/dominictarr/events{/privacy}","received_events_url":"https://api.github.com/users/dominictarr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2014-05-15T16:35:55Z","updated_at":"2015-03-16T15:34:12Z","closed_at":"2015-03-16T15:34:12Z","body":"'close' should not be emitted until everything is confirmed written.\r\nThis is analogous to the behavior of the file system: the file is not closed until after it's accepted all the writes - and it means that what has been written should be readable - and I think that post events (put, batch, del) should have fired already.\r\n\r\nthis line needs to move into the callback (of course there is a bit more state to check, but basically) Otherwise, it's not possible to know when a write stream has successfully written everything to the database.\r\n\r\nhttps://github.com/rvagg/node-levelup/blob/master/lib/write-stream.js#L149\r\n\r\nthis may also affect userland write streams... @Raynos @pgte @mcollina \r\n(it did those that I tried)\r\n\r\nI do have write stream that behaves correctly, if you use pull-level with pull-stream-to-stream.\r\n\r\nhttps://github.com/dominictarr/level-datablobs/blob/master/test/index.js#L45-L47\r\n\r\nI will put in a pull request, but am too busy right now."}}