microsoft / microsoft/vscode-extension-samples

Contentprovider sample often fails

Open
#287 1 comment 0 reactions 1 assignee View on GitHub

@jrieken is already working on this.

Since Oct 21, 2020.

bug
Dominant language
TypeScript
Stars
10.2k
Forks
3.9k
PR merge metrics
No merged PRs in 30d

Description

The Show All References command works sporadically for me. When it fails it prints something like Found 7 references in the right side window and fails to display the actual references. I strongly suspect this is a race condition.

I have a guess as to how to fix it, but I am not sure how to do it. The most sensible place to start would be here.

		for (const group of groups) {
			const uri = group[0].uri;
			const ranges = group.map(loc => loc.range);
			await this._fetchAndFormatLocations(uri, ranges);
			this._emitter.fire(this._uri);
		}

Drawing upon my experience with concurrency on the .NET platform (I am new to Node), I think the issue here is that this._emitter.fire(this._uri); is being called on the wrong thread. If this were a desktop UI app, I'd definitely want to schedule this on the main thread.

Any idea how this might be done with VS Code?

As a side note, when I insert...

const snooze = (ms : number) => new Promise(resolve => setTimeout(resolve, ms));
await snooze(1000);

...before the emitter fire, the stability issues go away. That is a strong indication of there being a concurrency bug here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.