Skip to content
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

fix(base): wait for all chunked requests to arrive before continuing #4017

Merged

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Dec 22, 2022

Description

Our previous approach of chunking document availability requests did not wait for all the chunks to finish before returning the results. The debounceCollect utility expects an observable that returns all results in one go, but because we returned a stream that would emit the chunks one-by-one as they arrived, we would only handle the first emission, which would not include the whole result set, breaking assumptions further down the line.

This patch fixes the issue by reducing over each emission, successively add them to an array. (the reduce operator will wait for the stream to finish before emitting a single reduced value).

What to review

  • Check that code looks ok
  • Make sure existence validation works as before
  • Make sure chunked existence requests are handled properly (this is rather tricky to verify without setting up lots of test data, but I've verified this for the repro case I was looking at, fwiw)

Notes for release

  • Fixes an issue that could give false validation errors for complex documents

Our previous approach of chunking document availability requests did not wait for all the chunks to finish before returning the results. The `debounceCollect` utility expects an observable that returns all results in one go, but because we returned a stream that would emit the chunks one-by-one as they arrived, we would only care about the first emission, which would not include the whole expected result set.

This patch fixes the issue by reducing over each emission, successively add them to an array. The `reduce` operator will wait for the stream to finish before emitting a single reduced value.
@bjoerge bjoerge requested a review from rexxars December 22, 2022 14:33
@vercel
Copy link

vercel bot commented Dec 22, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
studio-workshop ✅ Ready (Inspect) Visit Preview Dec 22, 2022 at 2:34PM (UTC)
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Dec 22, 2022 at 2:34PM (UTC)

Copy link
Member

@rexxars rexxars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find, lgtm

@bjoerge bjoerge merged commit 3b6915b into 2.x-next Dec 22, 2022
@bjoerge bjoerge deleted the bug/sc-28318/validation-errors-due-to-race-condition-in branch December 22, 2022 16:30
bjoerge added a commit that referenced this pull request Dec 22, 2022
…4017)

Our previous approach of chunking document availability requests did not wait for all the chunks to finish before returning the results. The debounceCollect utility expects an observable that returns all results in one go, but because we returned a stream that would emit the chunks one-by-one as they arrived, we would only handle the first emission, which would not include the whole result set, breaking assumptions further down the line.

This patch fixes the issue by reducing over each emission, successively add them to an array. (the reduce operator will wait for the stream to finish before emitting a single reduced value).
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.

None yet

2 participants