-
Notifications
You must be signed in to change notification settings - Fork 714
WIP Porting more completion tests and adding text change methods #8311
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
Draft
alexgav
wants to merge
2
commits into
main
Choose a base branch
from
dev/alexgav/MoreCompletionTests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
Oops, something went wrong.
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.
It seems a bit suspicious to be catching the cancellation error here specifically. It looks like the test itself is attempting to insert the text, but the insert gets cancelled. Wouldn't that fail the test because the text did not successfully get applied?
I wouldn't expect the actual insertion to get cancelled in general, unless someone else is changes the file underneath. I would generally expect other requests (e.g. a classification request) to get cancelled if you change the file - but I don't think that would cause the edit application itself to throw a cancellation?
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.
Cancellations and retries happen in razorDocumentSynchronizer during the text insertion. Text actually gets inserted and document gets synchronized eventually (thus re-tries while wiating for expected completion item).
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.
Though looking at the failures from the test run, I am catching them in the wrong place. At least some of the time synchronization appears to happen after the insertion/deletion (e.g. outside of insertText). I guess I could wrap test method itself including and after the modification operations.
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.
So if the synchronizer is changing the document underneath you may have to catch the exception here, think I get that part now (since the edit may fail).
If you're seeing them thrown outside of the insert text part, you probably want to catch them in the actual synchronization code path then? Unless some caller of it needs to observe the cancellation.
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.
it doesn't throw explicitly, at least not that I can easily see - I'll debug through that some more
vscode-csharp/src/razor/src/document/razorDocumentSynchronizer.ts
Line 143 in 3c12e27
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.
Maybe the rejection is happening outside of the await? The rejection happens for either
onCancellationRequested
orsetTimeout
. I'm not sure if those events could be triggered separately from the await, and therefore cause the promise rejection to not be handled?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.
Debugging it still, unfortunately the issue is pretty intermittent on my machine (though CI machines have no problem hitting it :) ).
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.
fwiw the code in there seems quite complex and a bit suspect in general. I wonder if it would be worth rewriting it instead of spending a bunch of time debugging. I'm no TS expert, but the multiple events rejecting the same promise, possibly entirely outside of the await context seems very prone to random issues.
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.
Unfortunately, I am neither TS expert nor razorDocumentSynchronizer expert, so I'm not up to the task of re-writing it. I debugged some more and tried a few things.
Cancellation seems to occur in request processing in request queue when previous requests of the same type is already running, which makes sense I guess. As we are inserting the text, we may hit previous request still running.
The unhandled error that jest sees is simply a string, not vscode.CancellationError. Also copilot did say it's a good practice to catch errors from rejection, so I added some catch clauses to the promises that seem to be the source of the errors. It seems to work on my machine, unless it's just flaky and not hitting the issue locally. I pushed the current fix and will see if the tests are passing on the CI now.
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.
After my last commit hover and rename tests are failing (though not on my box of course). I'll convert this PR to draft and mark with WIP while I figure out what's going on.