Skip to content

Add a special type instead of using a busy error for semantic tokens #93686

Closed

Description

Proposal for error name: UnavailableError / TemporaryUnavailableError (other: CancelError / BusyError / NotReadyError / RetryError)

This error should not appear in the extension host log (see #92583 where the busy error appears in the extension host log).

Activity

  1. midnight-dev commented on Mar 29, 2020

    @midnight-dev

    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.

    • AwaitingEcho
    • SemanticSync
    • CartBeforeTheHorse
    • MustRetry
    • StaleSemantics / StaleTokens
    • TokenMismatch
    • ResponseTooEarly / EagerResponseRaced
    • ThrottlingRequest

    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?

  2. alexdima commented on Mar 30, 2020

    @alexdima
    MemberAuthor

    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).

  3. alexdima commented on Mar 30, 2020

    @alexdima
    MemberAuthor

    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.

  4. added
    semantic-tokens
    feature-request
    on Mar 30, 2020
  5. jrieken commented on Apr 1, 2020

    @jrieken
    Contributor

    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

    1. call (busy) provider -> error
    2. call (busy) provider -> error
    3. provider becomes free -> fires event
    4. call (free) provider -> result
  6. alexdima commented on Apr 1, 2020

    @alexdima
    MemberAuthor

    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 --

    if (!err || typeof err.message !== 'string' || err.message.indexOf('busy') === -1) {
    errors.onUnexpectedError(err);
    }
    // Semantic tokens eats up all errors and considers errors to mean that the result is temporarily not available
    // The API does not have a special error kind to express this...
    this._currentDocumentRequestCancellationTokenSource = null;
    contentChangeListener.dispose();
    if (pendingChanges.length > 0) {
    // More changes occurred while the request was running
    if (!this._fetchDocumentSemanticTokens.isScheduled()) {
    this._fetchDocumentSemanticTokens.schedule();
    }
    }

    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.

  7. jrieken commented on Apr 1, 2020

    @jrieken
    Contributor

    Makes sense. Let's stick to the plan of specifying errors then

  8. 14 remaining items

  9. jrieken commented on Jan 13, 2021

    @jrieken
    Contributor

    Dirk Bäumer (@dbaeumer) This is now done and LSP should/could follow to make this available

  10. added
    unreleased
    on Jan 13, 2021
  11. dbaeumer commented on Jan 13, 2021

    @dbaeumer
    Member
  12. added
    insiders-released
    and removed
    unreleased
    on Jan 14, 2021
  13. added
    verification-needed
    on Jan 25, 2021
  14. jrieken commented on Jan 25, 2021

    @jrieken
    Contributor

    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

  15. added
    on-release-notes
    on Jan 25, 2021
  16. added
    verified
    on Jan 28, 2021
  17. dbaeumer commented on Jan 28, 2021

    @dbaeumer
    Member

    Johannes Rieken (@jrieken) qq: I was under the assumption that vscode.CancellationError is now official (not proposed anymore). Is this correct?

  18. locked and limited conversation to collaborators on Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-finalizationfeature-requestinsiders-releasedon-release-notessemantic-tokensverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions