Skip to content
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

Cancellation: More Problems #1567

Closed
cdietrich opened this issue Jul 2, 2024 · 5 comments
Closed

Cancellation: More Problems #1567

cdietrich opened this issue Jul 2, 2024 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@cdietrich
Copy link
Contributor

cdietrich commented Jul 2, 2024

From #1562 and #1566

Additionally to the missing notifications to the client we see more problems with cancellation respectively the recovery from it.

  • shouldRelink / unlink evaluates document.references only. but this wont be maintained if the document did not enter the linking phase before the cancellation, but during the linking of another document some references in that document are resolved in this document
  • changed files are just invalidated, but not unlinked, which leads to the same problem, as reparse might be skipped if content has not changed.

To be investigated:
at end of iterative deletes, not all delete validations seems to be have sent to the client

@cdietrich
Copy link
Contributor Author

workaround ideas:

override invalidateDocument(uri: URI): LangiumDocument | undefined {
    const result = super.invalidateDocument(uri)
    if (result !== undefined) {
      for (const node of AstUtils.streamAst(result.parseResult.value)) {
        AstUtils.streamReferences(node).forEach(refInfo => {
          const ref = refInfo.reference as DefaultReference
          if (ref._ref !== undefined) {
            delete ref._ref
            delete ref._nodeDescription
          }
        })
      }
    }
    return result
  }
protected override shouldRelink(document: LangiumDocument, changedUris: Set<string>): boolean {
    let result = super.shouldRelink(document, changedUris)

    if (!result) {
      for (const node of AstUtils.streamAst(document.parseResult.value)) {
        AstUtils.streamReferences(node).forEach(refInfo => {
          const ref = refInfo.reference as DefaultReference
          if (ref._ref !== undefined) {
            if (isLinkingError(ref._ref)) {
              result = true
            }
          }
        })
      }
    }
    return result
  }
override unlink(document: LangiumDocument): void {
    super.unlink(document)
    for (const node of AstUtils.streamAst(document.parseResult.value)) {
      AstUtils.streamReferences(node).forEach(refInfo => {
        const ref = refInfo.reference as DefaultReference
        if (ref._ref !== undefined) {
          delete ref._ref
          delete ref._nodeDescription
        }
      })
    }
  }

@cdietrich
Copy link
Contributor Author

cdietrich commented Jul 2, 2024

here is my attempts to reproduce the delete problem

main...cdietrich:langium:cd-repro2

but with longer timeouts it works....

@cdietrich
Copy link
Contributor Author

it looks like the delete problem might be a client side one.
i dont always see all deletes arrive at the server.

@cdietrich
Copy link
Contributor Author

created microsoft/vscode-languageserver-node#1503 for the client side clarification

@msujew
Copy link
Member

msujew commented Jul 4, 2024

Has been fixed with #1566. Release is available at [email protected].

@msujew msujew closed this as completed Jul 4, 2024
@spoenemann spoenemann added this to the v3.1.0 milestone Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants