-
Notifications
You must be signed in to change notification settings - Fork 749
fix(ec2): properly paginate instances in quickPick. #6682
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(ec2): properly paginate instances in quickPick. #6682
Conversation
|
| * A wrapper around Instance where we can safely assume InstanceId field exists. | ||
| */ | ||
| export interface SafeEc2Instance extends Instance { | ||
| export interface PatchedEc2Instance extends Instance { |
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.
would we have some other class for "unsafe"? or is that just an improvement that we are making in our wrapper class?
| export interface PatchedEc2Instance extends Instance { | |
| export interface Ec2Instance extends Instance { |
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.
This is an improvement here to make processing the responses easier. Avoids undefined checks in multiple places since we assert it once, and store that info in the type.
Problem
Follow up to discussion: #6672 (comment)
Currently the ec2 module does make paginated requests to the SDK endpoint. However, in order to show these results into the UI, we resolve them in entirety.
For the quick picks this is done here: https://github.com/aws/aws-toolkit-vscode/blob/4e568970e8d8646cf8e590d39d8891d68cebde84/packages/core/src/awsService/ec2/prompter.ts#L65
For the explorer this is done here: https://github.com/aws/aws-toolkit-vscode/blob/4e568970e8d8646cf8e590d39d8891d68cebde84/packages/core/src/awsService/ec2/explorer/ec2ParentNode.ts#L52
Solution
AsyncCollectionof pages to the quickPick.makePaginatedRequestby default.makePaginatedRequestto not return a promise.Ec2Promptertests, and refactor to test pagination behavior.Alternative Solution
Verification
In addition to updating the tests, we can add a logging statement when the quickPick loads an item from the

AsyncIterable. This screenshot shows that loading two items was successful and triggered theAsyncIterabletwice, as expected.Future Work
AsyncCollection, only making the requests directly. We could do something hacky, like wrap theAsyncCollectionin a fake request method, or try to refactor the utility itself.feature/xbranches will not be squash-merged at release time.