Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Delay diagnostics to give priority to other client requests #345

Merged
merged 3 commits into from
Sep 8, 2017

Conversation

tomv564
Copy link
Contributor

@tomv564 tomv564 commented Sep 4, 2017

This should remove an initial delay before the language server answers a completion request (see #331)
Currently uses setTimeout, would like to know about a preferable approach?

@@ -1267,7 +1267,7 @@ export class TypeScriptService {
// Ensure files needed for most operations are fetched
await this.projectManager.ensureReferencedFiles(uri).toPromise();
this.projectManager.didOpen(uri, params.textDocument.text);
this._publishDiagnostics(uri);
setTimeout(() => this._publishDiagnostics(uri), 200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if publishDiagnostics throws this crashes the process. I would do this:

await new Promise(resolve => setTimeout(resolve, 200))
this._publishDiagnostics(uri)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, all error handling out the window.
Cleaned up the tests after applying your suggestion, thanks for the help!

@codecov
Copy link

codecov bot commented Sep 4, 2017

Codecov Report

Merging #345 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #345      +/-   ##
==========================================
+ Coverage   60.03%   60.07%   +0.03%     
==========================================
  Files          14       14              
  Lines        2137     2139       +2     
  Branches      350      350              
==========================================
+ Hits         1283     1285       +2     
  Misses        705      705              
  Partials      149      149
Impacted Files Coverage Δ
src/typescript-service.ts 72.32% <100%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92df10f...6318209. Read the comment docs.

@felixfbecker felixfbecker merged commit 7777d8a into sourcegraph:master Sep 8, 2017
@tomv564 tomv564 deleted the add-diagnostics-delay branch September 9, 2017 09:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants