This repository has been archived by the owner. It is now read-only.

decodeStrings ignored when objectMode = true in stream.Writable #5580

Closed
chbrown opened this Issue May 28, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@chbrown

chbrown commented May 28, 2013

This is particularly unexpected with stream.Transform({decodeStrings: true, objectMode: true}), because in _transform(chunk, ...), chunk is sometimes a string.
Apparently objectMode trickles down into the Writable, and overrides the decodeStrings setting, but I only want it to apply to the Readable side, which is what I expected, since Writable's objectMode is undocumented.
I make it behave as expected by setting this._writableState.objectMode = false; in my Transform's constructor.

See https://gist.github.com/chbrown/5665509 for MWE.

@jasnell

This comment has been minimized.

Show comment Hide comment
@jasnell

jasnell May 26, 2015

Owner

@chbrown ... I know it's been a while, but is this still an issue for you. It's not clear from the sample case you provided.

Owner

jasnell commented May 26, 2015

@chbrown ... I know it's been a while, but is this still an issue for you. It's not clear from the sample case you provided.

@chbrown

This comment has been minimized.

Show comment Hide comment
@chbrown

chbrown May 27, 2015

@jasnell yeah kind of forgot about this issue — so I guess it really isn't one. stream.Transform is a tricky thing — double inheritance in Javascript's prototype paradigm. After reading through the node/lib/_stream_transform.js and node/lib/_stream_writable.js source, it makes sense. IIRC, my solution remains (setting this._writableState.objectMode directly), but I can see why I need to do that now.

chbrown commented May 27, 2015

@jasnell yeah kind of forgot about this issue — so I guess it really isn't one. stream.Transform is a tricky thing — double inheritance in Javascript's prototype paradigm. After reading through the node/lib/_stream_transform.js and node/lib/_stream_writable.js source, it makes sense. IIRC, my solution remains (setting this._writableState.objectMode directly), but I can see why I need to do that now.

@chbrown chbrown closed this May 27, 2015

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.