-
Notifications
You must be signed in to change notification settings - Fork 271
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
Fixing hasNext behaviour #1745
Merged
Merged
Fixing hasNext behaviour #1745
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
88f24e5
Revert "Set correctly `hasNext` for the last chunk of a deferred resp…
Geal 8d8ae23
WIP: attempt at fixing hasNext
Geal 69ab5bd
properly detect the end of stream
Geal 1d83d78
cleanup
Geal be8a0ab
Merge branch 'main' into geal/fix-hasnext
Geal 0093897
remove println
Geal 227e0cb
try to fix
Geal 31b2735
Merge branch 'main' into geal/fix-hasnext
Geal 1efd9a4
use Sender::disconnect to notify early that the sender will not be used
Geal 17e383a
filter empty responses
Geal fda59d3
fix
Geal 5210765
detect if the stream disconnected before marking the last message
Geal 2ddb5e9
Merge branch 'main' into geal/fix-hasnext
Geal d91fa00
changelog
Geal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
apollo-router/tests/snapshots/integration_tests__defer_path-2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
source: apollo-router/tests/integration_tests.rs | ||
assertion_line: 679 | ||
expression: second | ||
--- | ||
{ | ||
|
1 change: 1 addition & 0 deletions
1
apollo-router/tests/snapshots/integration_tests__defer_path_in_array-2.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
source: apollo-router/tests/integration_tests.rs | ||
assertion_line: 726 | ||
expression: second | ||
--- | ||
{ | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there may be a race condition here.
In the case where
stream.try_next()
is called and returns an error as there may be more items in the stream, if the stream is then closed before the call tonext
infilter_stream
, there will be no final empty response withhas_next: false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try_next
is like doingnext
but without await: if there's a message in the stream, it will be returned bytry_next
, if not thentry_next
will return an error and the next call tonext
would wait for it.In the case you are describing,
try_next
would not return an error if there are in flight messages. In the case wheretry_next
would return an error, then somehow between returning fromconsume_responses
and the call tonext
the stream gets new messages then is closed, thennext
would return a message, some calls totry_next
would return messages, then when there's nothing remainingtry_next
would return Ok(None)`.The one possible race I worry about is if messages are received and re-sent, then we await on
next
, then for whatever reason the stream is disconnected (maybe all the senders are dropped). Then we would need to add a finalhas_next = false
response. But I don't see how this could play outThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BrynCooke that last cvase should be addressed by 5210765
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!