You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ability to set highWaterMark on transform stream? #8855
I noticed that transform streams buffer up to 16kb (the default high watermark for read/write streams) even when they are not piping anywhere. I looked through the code/docs and it seems this value can't be set by implementers. As I'm writing a library which relies on this behaviour (transform buffering even when not piping to anywhere), I'd like to make sure it's not going to change and also was wondering if it would be possible for the Transform constructor to accept the highWaterMark option as well.
All of the constructors can already accept options, including highWaterMark. For example:
varTransform=require('stream').Transform;varinherits=require('util').inherits;functionMyTransform(opts){if(typeofopts!=='object'||opts===null)opts={};Transform.call(this,{highWaterMark: opts.highWaterMark});// Or just: `Transform.call(this, opts);`// Other initialization ...}inherits(MyTransform,Transform);MyTransform.prototype._transform=function(chunk,enc,cb){// ...};
Ok, thanks. Maybe I'm misunderstanding something then. I just tested the following code, which outputs 16384 instead of the expected 100 (highWaterMark) to the console:
highWaterMark is just an indicator to communicate to upstream that no more data should be written/pushed. Obviously you can write more data and it will just continue to be buffered in memory. highWaterMark does not dictate the size of chunks passed to _transform()/_write().
Activity
mscdex commentedon Sep 30, 2016
All of the constructors can already accept options, including
highWaterMark. For example:olalonde commentedon Sep 30, 2016
Ok, thanks. Maybe I'm misunderstanding something then. I just tested the following code, which outputs
16384instead of the expected100(highWaterMark) to the console:Is
highWaterMarka minimum which can possibly be exceeded?mscdex commentedon Sep 30, 2016
highWaterMarkis just an indicator to communicate to upstream that no more data should be written/pushed. Obviously you can write more data and it will just continue to be buffered in memory.highWaterMarkdoes not dictate the size of chunks passed to_transform()/_write().olalonde commentedon Sep 30, 2016
Ah ok, so it's more of a signal to upstream but not enforced, thanks.
kennylbj commentedon Sep 4, 2020
How can I set the chunk size in
_transformfunction?bbrzoska commentedon Jul 18, 2024
If you're here because your
@aws-sdk/lib-storageUpload code started failing after upgrading node from v18 to v22, and have this line:then try changing it to:
Which fixes the problem for me.