Fixed handling of backpressure in DaprChunkedStream #503
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The implementation of DaprChunkedStream (a Duplex stream which is currently used by the crypto APIs only, but can/will be used in other places in the future) did not handle backpressure correctly. In case the consumer's buffer was full, DaprChunkedStream closed the stream with an error, instead of more appropriately pausing consuming the stream from the Dapr sidecar.
This manifested in errors such as CI failures in the JS quickstarts, for example: https://github.com/dapr/quickstarts/actions/runs/5259159492/jobs/9504336466?pr=883 (which only appears in the CI where the agents are slower! and didn't appear in E2E tests in this repo because the consumer is in-memory, while that CI writes to a file)
A test has been added to confirm that the Duplex stream correctly handles backpressure by pausing the read.