Skip to content

Increase the idle time before which ensureProject for open file is called - #37121

Merged
Sheetal Nandi (sheetalkamat) merged 2 commits into
masterfrom
ensureProject
Mar 11, 2020
Merged

Sheetal Nandi (sheetalkamat) merged 2 commits into
masterfrom
ensureProject

Conversation

@sheetalkamat

@sheetalkamat Sheetal Nandi (sheetalkamat) commented Feb 28, 2020 •

Copy link
Copy Markdown
Member

This helps with rename case since we don't want to create inferred project just before editor sends updateOpen to close open file and open renamed file instead.. (Earlier the timeout ran before this updateOpen request)

As part of this I am also making logs little bit more concise given we print project structure when the structure changes.
So when printing all projects we print project names and its file count and open file and projects they are in.

Helps with #30535 delays

@amcasey

Copy link
Copy Markdown
Member

I think I'm missing something. What's the sequence of operations in the scenario that's causing problems? Guess:

  1. User opens a.ts
  2. Editor sends updateOpen for a.ts
  3. Server opens project for a.ts
  4. User renames a.ts to b.ts
  5. Editors sends updateOpen closing b.ts and opening a.ts
  6. Server confirms project is already open for b.ts?

What starts the timer?

@sheetalkamat

Copy link
Copy Markdown
Member Author

The scenario is as follows:

  1. User opens a.ts
  2. Editor sends updateOpen for a.ts
  3. Server opens project for a.ts
  4. User renames a.ts to b.ts
  5. Our watcher receives event that b.ts is created.. We schedule delayed update for configured project, and update to ensure project for each open file exists.
  6. The timeout results in updating configured project which now contains only b.ts
  7. timeout to ensure project for each open file which earlier was same amount of time as configured project update, runs which creates inferred project
  8. Editors sends updateOpen closing a.ts and opening b.ts => we remove inferred project

With this change, the timeout at point 8 is delayed so that in most cases it would be after point 8 so that we arent creating inferred project for a.ts

@amcasey

Copy link
Copy Markdown
Member

Sheetal Nandi (@sheetalkamat)
In (5), is there also an event indicating that a.ts has been deleted?
In (5), are the two updates on the same timer or different times?
In (6), the configured project contains b.ts because that happened to work without changes to tsconfig.json (e.g. it was covered by an existing glob)?
In (7), why is the inferred project created? I thought b.ts was no in the configured project and a.ts was gone.
In the endnote, did you mean "7", rather than "8"?

@sheetalkamat

Copy link
Copy Markdown
Member Author

(5) Whenever something changes we schedule update for the project and another timer to ensure projects for all open files. So at (5) schedules both. Note that a.ts and b.ts both are received as fileAddedOrRemoved event for configFile's wild card directory watching.
(6) Yes
(7) because a.ts is not on disk so its not root file of configured project so not included.. It becomes orphan and because its open we create inferred project for it.

Sorry about the confusion in the note.
With this change, the timeout at point 7 is delayed so that in most cases it would be after point 8 so that we arent creating inferred project for a.ts (as it doesn't exist and is not open)

@amcasey

Copy link
Copy Markdown
Member

Oh, I see - after we see the file events, we know a.ts is not on disk but we still believe it's open in the editor (i.e. as an unsaved buffer). That makes sense.

@amcasey Andrew Casey (amcasey) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given that we already have a race and a timeout, I see no harm in making the timeout longer. Doesn't seem to break VS (though it's hard to be certain with races involved).

@sheetalkamat
Sheetal Nandi (sheetalkamat) deleted the ensureProject branch March 11, 2020 23:47
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants