Skip to content

Conversation

jangxx
Copy link
Contributor

@jangxx jangxx commented Sep 24, 2020

I encountered a problem when sending some larger HTTP packets (a file upload) to this FastCGI server. For some reason, the "data" event would only fire once and the rest of the data would be buffered and not emitted. This single line fixed the issue, by setting _canPush to true, even if no data is buffered. A call to _read is a signal that more data is requested and that more data can therefore be pushed.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 65.553% when pulling 3e6cc3c on jangxx:master into 7022d3d on fbbdev:master.

@fbbdev
Copy link
Owner

fbbdev commented Jul 14, 2023

Thank you for reporting this and for the fix. I'm sorry for answering years later; I had to take a long hiatus from maintaining this package for personal reasons, and I also struggled to understand your fix.

For future reference, I'm gonna add an explanation below:

When the Node Stream API invokes the _read method, it expects the push method to be called with a non-empty data chunk before the _read method is invoked again; moreover, the _read method is never invoked again until push returns false.

We remember this condition by setting the _canPush property to true; however, because of how the _read method is written, _canPush is never set when our implementation-specific buffer is empty, leading to a stall in the data flow.

@fbbdev fbbdev merged commit 3461fdc into fbbdev:master Jul 14, 2023
fbbdev added a commit that referenced this pull request Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants