fix(product-assistant): correct exception to stop the async iterator #27101
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.
Problem
An async iterator must throw the StopAsyncIteration exception instead of a regular StopIteration. Currently, it doesn't happen, so the stream stays open until it gets killed by a timeout (my best guess now). After this fix, I haven't observed this issue locally on the ASGI webserver.
Related Sentry log.
Changes
sync_to_async
of asgiref can stop the iterator.Does this work well for both Cloud and self-hosted?
No
How did you test this code?
Unit tests.