-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Surprising behavior when chunk size > maxLength option #23
Comments
In the main transform function, the buffer length is checked before pushing any fully terminated lines. Would it make more sense to check the length of the buffer after pushing terminated lines? |
This seems to pass all current tests as well as the one in this issue:
|
Sure, would you like to send a PR? |
I can do that. With the change described above, it delays the error until the buffer (meaning I happened to stumble upon this because I was adding an alternative overflow behavior for my use case where the stream seeks to the start of the next line rather than erroring-out when The behavior is described in this test:
Would you be interested in a PR for this alternative overflow behavior as well? |
go for it |
Also adds a test to catch surprising maxLength behavior described in mcollina#23
Also addresses surprising maxLength behavior described in mcollina#23
Also addresses surprising maxLength behavior described in mcollina#23
Also addresses surprising maxLength behavior described in mcollina#23
Also addresses surprising maxLength behavior described in mcollina#23
Also addresses surprising maxLength behavior described in mcollina#23
Fixed in 3.1.0 and #24. |
My expectation of the
maxLength
option is that the stream will error when buffering of any one line grows the buffer to exceed the given length. I understand this may not match the true intent of this option, but I'd like to ask for clarification. The surprising behavior occurs when processing a chunk larger than themaxLength
option, but also contains no lines that individually exceedmaxLength
.This is more easily demonstrated in this test:
This is surprising because it should be very common for the typical chunk size to be much greater than the typical line length. The
maxLength
option could therefore only be useful when set to at least twice the typical chunk size. Since a stream can't control the size of chunks it receives, this seems like a logic error.Could you please comment?
The text was updated successfully, but these errors were encountered: