microsoft / microsoft/TypeScript

Keep TSServer alive longer for initialization performance

Open
#39,844 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Domain: LS: TSServer In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Hello! First off, thank you for your work on VSCode -- by far my favorite and the most popular editor at my company.

I work in a very large monorepo, with 5M lines of TS, across ~70k TS files, across ~900 projects (here is a small scale reproduction of our setup: https://github.com/brieb/ts-monorepo/).

While working in a monorepo, its common to jump between files in different projects. Each time a file is opened for a new project, the TS server needs to be initialized ("Initializing JS/TS language features"). For some of our largest projects, this can take up to a minute. But if that file is closed during the course of the editing session, the corresponding TS/JS server is shutdown, and you'd have to wait another minute when coming back to a file in that project.

Some people have hacked around this by deliberately keeping tabs open for files in each of the projects they are working in even when they are done with the file (but not the project) to keep the TS server alive and avoid paying that startup cost.

Curious if you've run into or thought about this problem before and have ideas for improving this workflow

One idea could be making the shutdown behavior configurable -- immediate (today's behavior), timeout-based (after a certain timeout with no project activity the server is shutdown).

Hopefully this feature could benefit others that work in a similar monorepo environment too.

keywords: tsserver, persist, persistence, keep alive, initialize, initializing, monorepo

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.

Research direction

Start with the linked ts-monorepo reproduction and investigate how tsserver shuts down projects after their files are closed. Define a concrete configurable or timeout-based keep-alive behavior, then verify that revisiting files in the same project avoids repeated initialization delays.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, performance, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.