You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add a special type instead of using a busy error for semantic tokens #93686
I'm not planning on digging into the backbone of semantic tokens quite yet, so grain of salt with this suggestion...
That said, I understand this to be a special event that could be seen dozens of times every other minute, and it's not really an error as you explained earlier. Is there any particular reason to classify it as an error (besides it being thrown like one)? If it's policy, I get it. But it seems to fit much more in with notices / notifications rather than errors. Not sure how unique it should be to the semantic tokens provider, but here are some ideas.
We have agreed to expose this as an error to align with the way cancelation works inside VS Code. When canceling a request that returns a Promise, the current contract is that the Promise will resolve with the error callback with a special error kind.
We have discussed and found that this "unavailable" case is very similar to client-side cancelation, but it is server-side cancelation. We have therefore found that exercising the error callback of the promise makes most sense (again, to align with the client side cancelation).
When canceling a request that returns a Promise, the current contract is that the Promise will resolve with the error callback with a special error kind.
In all fairness, that's something that winjs-promise inherited to us and something that we never changed after dropping winjs. In the API we don't care what happens after cancellation, we ignore everything that comes after cancellation.
Still, spec'ing an error isn't alien to the API. A case for spec'ed errors and unspecific errors is the FileSystemProvider and RenameProvider.
the RenameProvider#provideRenameEdits function can reject its promise with an unspecified error when the new name isn't valid. In the UI we then try to extract a meaningful message. An unspecific error isn't a problem here because we need to report any rename-error to the user anyways.
the FileSystemProvider defines the FileSystemError including various flavours of that, like FileSystemError.FileNotFound. For instance FileSystemProvider#stat uses an error (FileSystemError.FileNotFound) to communicate that a file doesn't exists and it does not support to return null or undefined to express that a file doesn't exist. We use specific errors here because handling of non-existent files is usually different from handling general IO errors.
For semantic tokens we have to make the same decisions - unspecific errors and uniform handling of those or specific errors that trigger specific logic. From where we stand today the specific error case make sense but Alexandru Dima (@alexdima) did we consider to have no specific error and simply ask provider to fire the onDidChangeSemanticTokens when it's free again. So, it would be like this
Johannes Rieken (@jrieken) Actually, that is the current implementation, all errors behave the same way, the only special thing about 'busy' errors is that they are not logged --
But I would like to implement a more involved error handling strategy. The semantic tokens request can be either a full document request, or a delta document request. I would like to implement the following:
1. If the error is a 'busy' (typed) error
keep the existing semantic tokens
try again the delta request with some timeouts (1s, 5s, 5s, 5s, 5s, give up)
if after 5 times there is still a 'busy' error from the delta request, stop requesting and wait for a change event from the provider or for user typing...
2. If the error is another kind of error
keep the existing semantic tokens
try again with a single full document request (after 1s)
if it fails, wait for a change event from the provider or for user typing
So one kind of error would make delta requests, while the other kind of errors would give up on the deltas and make a full document request. It is kind of involved, but that would give a way out of an accidental programming mistake where for whatever reason a certain delta would throw in the provider... it will self-heal with a full document request if an error is returned to the delta request...
TL;DR: I would like to behave slightly differently in the busy error case and in the unexpected error case.
Verify that you can use vscode.CancellationError with requiring proposed API checks. Optionally, verify that you throw this error from a semantic tokens provider without it resetting previous semantic tokens
Activity
midnight-dev commentedon Mar 29, 2020
I'm not planning on digging into the backbone of semantic tokens quite yet, so grain of salt with this suggestion...
That said, I understand this to be a special event that could be seen dozens of times every other minute, and it's not really an error as you explained earlier. Is there any particular reason to classify it as an error (besides it being thrown like one)? If it's policy, I get it. But it seems to fit much more in with notices / notifications rather than errors. Not sure how unique it should be to the semantic tokens provider, but here are some ideas.
Followed by any of these suffixes:
Notice / Info / Exception / Event / Hook / Warning / Error
Perhaps something with "busy" somewhere in the name so telemetry doesn't get slammed with statistics?
alexdima commentedon Mar 30, 2020
We have agreed to expose this as an error to align with the way cancelation works inside VS Code. When canceling a request that returns a Promise, the current contract is that the Promise will resolve with the error callback with a special error kind.
We have discussed and found that this "unavailable" case is very similar to client-side cancelation, but it is server-side cancelation. We have therefore found that exercising the error callback of the promise makes most sense (again, to align with the client side cancelation).
alexdima commentedon Mar 30, 2020
Johannes Rieken (@jrieken) This didn't make it in time. Let's chat tomorrow what would be best...
IMHO we could ship as is (with supporting an error with the message
busy)...We can remove that in a couple milestones once we have a better error type, but I would not want to block to wait on that.
jrieken commentedon Apr 1, 2020
In all fairness, that's something that winjs-promise inherited to us and something that we never changed after dropping winjs. In the API we don't care what happens after cancellation, we ignore everything that comes after cancellation.
Still, spec'ing an error isn't alien to the API. A case for spec'ed errors and unspecific errors is the
FileSystemProviderandRenameProvider.RenameProvider#provideRenameEditsfunction can reject its promise with an unspecified error when the new name isn't valid. In the UI we then try to extract a meaningful message. An unspecific error isn't a problem here because we need to report any rename-error to the user anyways.FileSystemProviderdefines theFileSystemErrorincluding various flavours of that, likeFileSystemError.FileNotFound. For instanceFileSystemProvider#statuses an error (FileSystemError.FileNotFound) to communicate that a file doesn't exists and it does not support to returnnullorundefinedto express that a file doesn't exist. We use specific errors here because handling of non-existent files is usually different from handling general IO errors.For semantic tokens we have to make the same decisions - unspecific errors and uniform handling of those or specific errors that trigger specific logic. From where we stand today the specific error case make sense but Alexandru Dima (@alexdima) did we consider to have no specific error and simply ask provider to fire the
onDidChangeSemanticTokenswhen it's free again. So, it would be like thisalexdima commentedon Apr 1, 2020
Johannes Rieken (@jrieken) Actually, that is the current implementation, all errors behave the same way, the only special thing about 'busy' errors is that they are not logged --
vscode/src/vs/editor/common/services/modelServiceImpl.ts
Lines 766 to 780 in f3db6a8
But I would like to implement a more involved error handling strategy. The semantic tokens request can be either a full document request, or a delta document request. I would like to implement the following:
1. If the error is a 'busy' (typed) error
2. If the error is another kind of error
So one kind of error would make delta requests, while the other kind of errors would give up on the deltas and make a full document request. It is kind of involved, but that would give a way out of an accidental programming mistake where for whatever reason a certain delta would throw in the provider... it will self-heal with a full document request if an error is returned to the delta request...
TL;DR: I would like to behave slightly differently in the
busyerror case and in the unexpected error case.jrieken commentedon Apr 1, 2020
Makes sense. Let's stick to the plan of specifying errors then
14 remaining items
jrieken commentedon Jan 13, 2021
Dirk Bäumer (@dbaeumer) This is now done and LSP should/could follow to make this available
dbaeumer commentedon Jan 13, 2021
Johannes Rieken (@jrieken). Cool. Will add it to my list (microsoft/vscode-languageserver-node#729)
jrieken commentedon Jan 25, 2021
Verify that you can use
vscode.CancellationErrorwith requiring proposed API checks. Optionally, verify that you throw this error from a semantic tokens provider without it resetting previous semantic tokensdbaeumer commentedon Jan 28, 2021
Johannes Rieken (@jrieken) qq: I was under the assumption that
vscode.CancellationErroris now official (not proposed anymore). Is this correct?Squashed 'lib/vscode/' changes from 3e344b17b7b..622cb03
finalize CancellationError API, fixes microsoft/vscode#93686