{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node-v0.x-archive/issues/8872","labels_url":"https://api.github.com/repos/nodejs/node-v0.x-archive/issues/8872/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node-v0.x-archive/issues/8872/comments","events_url":"https://api.github.com/repos/nodejs/node-v0.x-archive/issues/8872/events","html_url":"https://github.com/nodejs/node-v0.x-archive/issues/8872","id":51978006,"number":8872,"title":"Transform stream in objectMode disallows null","user":{"login":"freeformsystems","id":238069,"avatar_url":"https://avatars.githubusercontent.com/u/238069?v=3","gravatar_id":"","url":"https://api.github.com/users/freeformsystems","html_url":"https://github.com/freeformsystems","followers_url":"https://api.github.com/users/freeformsystems/followers","following_url":"https://api.github.com/users/freeformsystems/following{/other_user}","gists_url":"https://api.github.com/users/freeformsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/freeformsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freeformsystems/subscriptions","organizations_url":"https://api.github.com/users/freeformsystems/orgs","repos_url":"https://api.github.com/users/freeformsystems/repos","events_url":"https://api.github.com/users/freeformsystems/events{/privacy}","received_events_url":"https://api.github.com/users/freeformsystems/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-12-15T11:59:46Z","updated_at":"2015-09-29T06:26:00Z","closed_at":"2015-09-29T06:26:00Z","body":"When a Transform stream has `objectMode` enabled the `_transform` method is never called when a `null` value is written to the stream.\r\n\r\nI believe that when `objectMode` is enabled a `null` value should pass through because many serialisation formats need to represent `null`, interestingly `undefined` does get passed to `_transform` and I believe it still should (I handle it for my use case).\r\n\r\nI believe the culprit is here:\r\n\r\nhttps://github.com/joyent/node/blob/master/lib/_stream_transform.js#L177\r\n\r\nAnd the fix is to test against `this._readableState.objectMode`, a quick patch I whipped up against an earlier version of that file for my immediate scenario where I absolutely needed to be able to write `null` now:\r\n\r\n```javascript\r\nif ((ts.writechunk !== null || this._readableState.objectMode)\r\n  && ts.writecb && !ts.transforming)\r\n```\r\n\r\nIncidentally, while reading the code it looks to me like:\r\n\r\nhttps://github.com/joyent/node/blob/master/lib/_stream_transform.js#L79-L80\r\n\r\nAre never used and should be removed, legacy code I think."},"comment":{"url":"https://api.github.com/repos/nodejs/node-v0.x-archive/issues/comments/143957814","html_url":"https://github.com/nodejs/node-v0.x-archive/issues/8872#issuecomment-143957814","issue_url":"https://api.github.com/repos/nodejs/node-v0.x-archive/issues/8872","id":143957814,"user":{"login":"brendanashworth","id":3038254,"avatar_url":"https://avatars.githubusercontent.com/u/3038254?v=3","gravatar_id":"","url":"https://api.github.com/users/brendanashworth","html_url":"https://github.com/brendanashworth","followers_url":"https://api.github.com/users/brendanashworth/followers","following_url":"https://api.github.com/users/brendanashworth/following{/other_user}","gists_url":"https://api.github.com/users/brendanashworth/gists{/gist_id}","starred_url":"https://api.github.com/users/brendanashworth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brendanashworth/subscriptions","organizations_url":"https://api.github.com/users/brendanashworth/orgs","repos_url":"https://api.github.com/users/brendanashworth/repos","events_url":"https://api.github.com/users/brendanashworth/events{/privacy}","received_events_url":"https://api.github.com/users/brendanashworth/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T06:25:59Z","updated_at":"2015-09-29T06:25:59Z","body":"I don't think this is a bug - but if you'd like to pursue this further, you'd do better to open a new issue here: https://github.com/nodejs/node. This repo is now an archive and nobody really pays attention to it :)."}}