-
Notifications
You must be signed in to change notification settings - Fork 751
fix(inline-suggestion): replace vscode.cancellation with waitUntil for timeout #6256
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
Conversation
This file contains hidden or 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 comment was marked as resolved.
This comment was marked as resolved.
Will-ShaoHua
commented
Dec 16, 2024
| }) | ||
|
|
||
| it('for control group, should return opentabs context where there will be 3 chunks and each chunk should contains 50 lines', async function () { | ||
| it.skip('for control group, should return opentabs context where there will be 3 chunks and each chunk should contains 50 lines', async function () { |
Contributor
Author
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.
we always assume t1 group for now
leigaol
approved these changes
Dec 16, 2024
Contributor
Author
|
looking into test failure |
justinmk3
approved these changes
Dec 16, 2024
karanA-aws
pushed a commit
to karanA-aws/aws-toolkit-vscode
that referenced
this pull request
Jan 17, 2025
…r timeout (aws#6256) ## Problem related issue: aws#6079, aws#6252 caller ``` function main () { // init vscode cancellation token const cancellationToken setTimeout(100, () => { cancellationToken.cancel() }) highlevelWrapperFetchSupplementalContext(editor, cancellationToken) } ``` ``` export function highlevelWrapperFetchSupplementalContext(editor, cancellationToken) { const supplementalContext = waitUntil(100, () => { // here always timeout and throw TimeoutException const opentabs = await fetchOpenTabsContext(...) const projectContext = await fetchProjectContext() const result = [] if (projectContext not empty) { // push project context } if (opentabs not empty) {} // push openttabs }) return result } async function fetchOpenTabsContext(editor, cancellationToken) { .... // VSC api call } async function fetchProjectContext() { .... // LSP call } ``` After investigation, it looks like mix use of `vscode.CancellationToken` and `waitUntil()` will likely cause cancellation token to be cancelled prematurely (might be because another layer of waitUntil will run the fetchOpenTabsContext asynchronously thus causing it to timeout prematurely) therefore `fetchOpebtabsContext(..)` will return null in this case and hence causing test cases failing. Therefore, the issue here is actually not the test case itself and they're failing due to race condition ## Solution remove usage of cancellation token and only use waitUntil for timeout purpose ## Functional testing retrieved sup context as expected ### Case 1: repomap is available (there are local imports) ``` 2024-12-16 13:10:15.616 [debug] CodeWhispererSupplementalContext: isUtg: false, isProcessTimeout: false, contentsLength: 14436, latency: 16.67179101705551 strategy: codemap Chunk 0: Path: q-inline Length: 10209 Score: 0 Chunk 1: Path: /Volumes/workplace/ide/aws-toolkit-vscode-staging/packages/core/src/codewhisperer/service/serviceContainer.ts Length: 1486 Score: 22.60257328587725 Chunk 2: Path: /Volumes/workplace/ide/aws-toolkit-vscode-staging/packages/core/src/codewhisperer/tracker/lineTracker.ts Length: 1649 Score: 19.106700952807103 Chunk 3: Path: /Volumes/workplace/ide/aws-toolkit-vscode-staging/packages/core/src/codewhisperer/tracker/lineTracker.ts Length: 1092 Score: 10.334690655691002 ``` ### Case 2: No repomap, should fallback to opentabs only  ``` 2024-12-16 13:11:29.738 [debug] CodeWhispererSupplementalContext: isUtg: false, isProcessTimeout: false, contentsLength: 5046, latency: 16.311500012874603 strategy: opentabs Chunk 0: Path: /Volumes/workplace/ide/aws-toolkit-vscode-staging/packages/core/src/codewhisperer/tracker/lineTracker.ts Length: 1564 Score: 0 Chunk 1: Path: /Volumes/workplace/ide/aws-toolkit-vscode-staging/packages/core/src/codewhisperer/tracker/lineTracker.ts Length: 1649 Score: 0 Chunk 2: Path: /Volumes/workplace/ide/aws-toolkit-vscode-staging/packages/core/src/codewhisperer/tracker/lineTracker.ts Length: 1833 Score: 0 ``` --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
related issue: #6079, #6252
caller
After investigation, it looks like mix use of
vscode.CancellationTokenandwaitUntil()will likely cause cancellation token to be cancelled prematurely (might be because another layer of waitUntil will run the fetchOpenTabsContext asynchronously thus causing it to timeout prematurely) thereforefetchOpebtabsContext(..)will return null in this case and hence causing test cases failing.Therefore, the issue here is actually not the test case itself and they're failing due to race condition
Solution
remove usage of cancellation token and only use waitUntil for timeout purpose
Functional testing
retrieved sup context as expected
Case 1: repomap is available (there are local imports)
Case 2: No repomap, should fallback to opentabs only
feature/xbranches will not be squash-merged at release time.License: I confirm that my contribution is made under the terms of the Apache 2.0 license.