Skip to content

Fixed handling of backpressure in DaprChunkedStream #503

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

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

ItalyPaleAle
Copy link
Contributor

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.

Streams are fun 🙃

@ItalyPaleAle ItalyPaleAle requested review from a team as code owners June 13, 2023 21:12
@ItalyPaleAle ItalyPaleAle force-pushed the fix-stream-backpressure branch from 6818193 to 1f857b0 Compare June 13, 2023 21:15
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
@codecov
Copy link

codecov bot commented Jun 13, 2023

Codecov Report

Merging #503 (092362d) into main (553431f) will decrease coverage by 0.02%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #503      +/-   ##
==========================================
- Coverage   35.70%   35.69%   -0.02%     
==========================================
  Files          87       87              
  Lines       10122    10125       +3     
  Branches      412      414       +2     
==========================================
  Hits         3614     3614              
- Misses       6449     6452       +3     
  Partials       59       59              
Impacted Files Coverage Δ
src/utils/Streams.util.ts 6.12% <0.00%> (-0.40%) ⬇️

@XavierGeerinck XavierGeerinck added this pull request to the merge queue Jun 14, 2023
Merged via the queue into dapr:main with commit 0b881c2 Jun 14, 2023
@XavierGeerinck
Copy link
Contributor

Merged into main! Thanks for contributing this one, will make a hotfix release

@ItalyPaleAle ItalyPaleAle deleted the fix-stream-backpressure branch June 26, 2023 16:11
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.

2 participants