Skip to content

Race condition detected between program updates and ATA(?) #2275

@DanielRosenwasser

Description

@DanielRosenwasser
{"kind":"request","method":"initialize","params":{"processId":13346,"capabilities":{"textDocument":{"completion":{"completionItem":{"snippetSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"commitCharactersSupport":true,"deprecatedSupport":true,"preselectSupport":true,"labelDetailsSupport":true,"documentationFormat":["markdown","plaintext"],"insertTextModeSupport":{"valueSet":[1,2]}},"contextSupport":true},"definition":{"linkSupport":true},"references":{},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true,"labelSupport":true},"foldingRange":{"foldingRange":{"collapsedText":true}},"codeAction":{"disabledSupport":true,"dataSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"hover":{"contentFormat":["markdown","plaintext"]},"diagnostic":{"relatedDocumentSupport":true},"declaration":{"linkSupport":true},"implementation":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"rename":{}},"workspace":{"symbol":{}}},"rootUri":"@PROJECT_ROOT@"}}
{"kind":"notification","method":"initialized","params":{}}
{"kind":"notification","method":"textDocument/didOpen","params":{"textDocument":{"uri":"@PROJECT_ROOT@someScript.mts","languageId":"typescript","version":1,"text":"function hello(){}"}}}
{"kind":"notification","method":"textDocument/didOpen","params":{"textDocument":{"uri":"@PROJECT_ROOT@otherFile.ts","languageId":"typescript","version":14,"text":"\nexport function bbb(){}"}}}
{"kind":"notification","method":"textDocument/didChange","params":{"textDocument":{"uri":"@PROJECT_ROOT@otherFile.ts","version":15},"contentChanges":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"text":" //comment"}]}}
{"kind":"request","method":"textDocument/completion","params":{"textDocument":{"uri":"@PROJECT_ROOT@otherFile.ts"},"position":{"line":0,"character":0},"context":{"triggerKind":1}}}
==================
WARNING: DATA RACE
Read at 0x00c005f8fbc0 by goroutine 1376:
  github.com/microsoft/typescript-go/internal/compiler.(*Program).UpdateProgram()
      /workspaces/typescript-go/internal/compiler/program.go:252 +0x5f0
  github.com/microsoft/typescript-go/internal/project.(*Project).CreateProgram()
      /workspaces/typescript-go/internal/project/project.go:324 +0x1bc
  github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).updateProgram.func1.2()
      /workspaces/typescript-go/internal/project/projectcollectionbuilder.go:979 +0x5cd
  github.com/microsoft/typescript-go/internal/project/dirty.(*Box[go.shape.*uint8]).Change()
      /workspaces/typescript-go/internal/project/dirty/box.go:41 +0xe9
  github.com/microsoft/typescript-go/internal/project/dirty.(*Box[*github.com/microsoft/typescript-go/internal/project.Project]).Change()
      /workspaces/typescript-go/internal/project/dirty/box.go:36 +0x44
  github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).updateProgram.func1()
      /workspaces/typescript-go/internal/project/projectcollectionbuilder.go:976 +0x413
  github.com/microsoft/typescript-go/internal/project/dirty.(*Box[go.shape.*uint8]).Locked()
      /workspaces/typescript-go/internal/project/dirty/box.go:57 +0x4c
  github.com/microsoft/typescript-go/internal/project/dirty.(*Box[*github.com/microsoft/typescript-go/internal/project.Project]).Locked()
      /workspaces/typescript-go/internal/project/dirty/box.go:56 +0x17
  github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).updateProgram()
      /workspaces/typescript-go/internal/project/projectcollectionbuilder.go:950 +0x218
  github.com/microsoft/typescript-go/internal/project.(*ProjectCollectionBuilder).DidRequestFile()
      /workspaces/typescript-go/internal/project/projectcollectionbuilder.go:350 +0x194
  github.com/microsoft/typescript-go/internal/project.(*Snapshot).Clone()
      /workspaces/typescript-go/internal/project/snapshot.go:291 +0x1224
  github.com/microsoft/typescript-go/internal/project.(*Session).UpdateSnapshot()
      /workspaces/typescript-go/internal/project/session.go:520 +0xf2
  github.com/microsoft/typescript-go/internal/project.(*Session).getSnapshot()
      /workspaces/typescript-go/internal/project/session.go:398 +0x412
  github.com/microsoft/typescript-go/internal/project.(*Session).getSnapshotAndDefaultProject()
      /workspaces/typescript-go/internal/project/session.go:448 +0x13c
  github.com/microsoft/typescript-go/internal/project.(*Session).GetLanguageService()
      /workspaces/typescript-go/internal/project/session.go:460 +0x52
  github.com/microsoft/typescript-go/internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[go.shape.*uint8,go.shape.struct { Items *[]*github.com/microsoft/typescript-go/internal/lsp/lsproto.CompletionItem; List *github.com/microsoft/typescript-go/internal/lsp/lsproto.CompletionList }].16()
      /workspaces/typescript-go/internal/lsp/server.go:616 +0x15b
  github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification()
      /workspaces/typescript-go/internal/lsp/server.go:502 +0x23d
  github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
      /workspaces/typescript-go/internal/lsp/server.go:405 +0x64

Previous write at 0x00c005f8fbc0 by goroutine 1334:
  github.com/microsoft/typescript-go/internal/project.(*Project).GetUnresolvedImports.(*Program).GetUnresolvedImports.func1()
      /workspaces/typescript-go/internal/compiler/program.go:323 +0x5e
  sync.(*Once).doSlow()
      /usr/local/go/src/sync/once.go:78 +0xd1
  sync.(*Once).Do()
      /usr/local/go/src/sync/once.go:69 +0x44
  github.com/microsoft/typescript-go/internal/compiler.(*Program).GetUnresolvedImports()
      /workspaces/typescript-go/internal/compiler/program.go:321 +0xa4
  github.com/microsoft/typescript-go/internal/project.(*Project).GetUnresolvedImports()
      /workspaces/typescript-go/internal/project/project.go:435 +0x4a
  github.com/microsoft/typescript-go/internal/project.(*Project).ComputeTypingsInfo()
      /workspaces/typescript-go/internal/project/project.go:460 +0x1ac
  github.com/microsoft/typescript-go/internal/project.(*Session).triggerATAForUpdatedProjects.func1()
      /workspaces/typescript-go/internal/project/session.go:874 +0x1e4
  github.com/microsoft/typescript-go/internal/project/background.(*Queue).Enqueue.func1()
      /workspaces/typescript-go/internal/project/background/queue.go:29 +0x46
  sync.(*WaitGroup).Go.func1()
      /usr/local/go/src/sync/waitgroup.go:239 +0x5d

Goroutine 1376 (running) created at:
  github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop()
      /workspaces/typescript-go/internal/lsp/server.go:425 +0x9c8
  github.com/microsoft/typescript-go/internal/lsp.(*Server).Run.func1()
      /workspaces/typescript-go/internal/lsp/server.go:301 +0x46
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /go/pkg/mod/golang.org/x/sync@v0.18.0/errgroup/errgroup.go:93 +0x86

Goroutine 1334 (running) created at:
  sync.(*WaitGroup).Go()
      /usr/local/go/src/sync/waitgroup.go:237 +0x86
  github.com/microsoft/typescript-go/internal/project/background.(*Queue).Enqueue()
      /workspaces/typescript-go/internal/project/background/queue.go:28 +0x11e
  github.com/microsoft/typescript-go/internal/project.(*Session).triggerATAForUpdatedProjects()
      /workspaces/typescript-go/internal/project/session.go:868 +0x188
  github.com/microsoft/typescript-go/internal/project.(*Session).UpdateSnapshot()
      /workspaces/typescript-go/internal/project/session.go:531 +0x1c5
  github.com/microsoft/typescript-go/internal/project.(*Session).DidOpenFile()
      /workspaces/typescript-go/internal/project/session.go:241 +0x497
  github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDidOpen()
      /workspaces/typescript-go/internal/lsp/server.go:1113 +0x198
  github.com/microsoft/typescript-go/internal/lsp.init.func1.registerNotificationHandler[go.shape.*uint8].6()
      /workspaces/typescript-go/internal/lsp/server.go:575 +0x412
  github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification()
      /workspaces/typescript-go/internal/lsp/server.go:502 +0x23d
  github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
      /workspaces/typescript-go/internal/lsp/server.go:405 +0x832
  github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop()
      /workspaces/typescript-go/internal/lsp/server.go:423 +0x818
  github.com/microsoft/typescript-go/internal/lsp.(*Server).Run.func1()
      /workspaces/typescript-go/internal/lsp/server.go:301 +0x46
  golang.org/x/sync/errgroup.(*Group).Go.func1()
      /go/pkg/mod/golang.org/x/sync@v0.18.0/errgroup/errgroup.go:93 +0x86
==================

Metadata

Metadata

Assignees

Labels

Domain: EditorRelated to the LSP server, editor experience

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions